Accessing data by using a row-positioned cursor

A row-positioned cursor points to a single row and retrieves at most a single row at a time from the result segment. You can specify a fetch request to specify which rows to retrieve, relative to the current cursor position.

Procedure

To access data by using a row-positioned cursor:

  1. Execute a DECLARE CURSOR statement to define the result segment on which the cursor operates. See Declaring a row cursor.
  2. Execute an OPEN CURSOR to make the cursor available to the application. See Opening a row cursor.
  3. Specify what the program is to do when all rows have been retrieved. See Specifying the action that the row cursor is to take when it reaches the end of the data.
  4. Execute the SQL statements to retrieve data from the segment. See Executing SQL statements by using a row cursor.
  5. Execute a CLOSE CURSOR statement to make the cursor unavailable to the application. See Closing a row cursor.

Your program can have several cursors, each of which performs the previous steps.