Cursors are defined in the Procedure Division or in the Data Division. For example:
EXEC SQL DECLARE MYCURSOR CURSOR FOR SELECT FIRST_NAME, LAST_NAME FROM TEST_TABLE END-EXEC.
AcuSQL also supports the declaration of scroll cursors, and the use of the following FETCH extensions:
|Returns the first row of query results.
|Returns the last row of query results.
|Returns the row immediately preceding the current curser row.
|Returns the row immediately following the current curser row.
|Returns a specific row identified by a constant or host variable*.
|Moves the cursor forward or backward a specified number of times from its current position.
* If specifying a row position through a host variable, the host variable does not need to be declared in the DECLARE section of working-storage, and can be any numeric working-storage variable.
See Cursors for a brief introduction to cursors. Refer to any of the commercially available books on SQL for more complete details.