Accessing data by using a row-positioned cursor

A row-positioned cursor is a cursor that points to a single row and retrieves at most a single row at a time from the result table. 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 table 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 multiple SQL statements to retrieve data from the table or modify selected rows of the table. 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.

Results

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