A cursor allows you to return the results of a SELECT in the form of a data type called a cursor. A cursor is similar to a table, but has the additional property that one row is identified as the present, or current row. Various commands allow you to navigate through the rows of a cursor. For example, the FETCH command retrieves a row from the cursor and identifies it as the current row. You can step through all the rows in a cursor by calling this command repeatedly.
Cursors are of most use when you program procedures, or when you write applications that access a database using Embedded SQL. They are also used by many front-end query tools. They are not available when using DBISQL interactively.
Sybase IQ cursors are updatable, which allows you to modify the underlying data in the database while processing a cursor.
The rows in a cursor, like those in a table, have no order associated with them. The FETCH command steps through the rows, but the order may appear random and can even be inconsistent. For this reason, you will want to impose an order by appending an ORDER BY phrase to your SELECT statement.
The sp_iqcursorinfo stored procedure displays information about cursors currently open on the server. For more information, see “sp_iqcursorinfo procedure” in Chapter 7, “System Procedures,” in Reference: Building Blocks, Tables, and Procedures.