Accessing data by using a rowset-positioned cursor

A rowset-positioned cursor is a cursor that can return one or more rows for a single fetch operation. The cursor is positioned on the set of rows that are to be fetched.

Procedure

To access data by using a rowset-positioned cursor:

  1. Execute a DECLARE CURSOR statement to define the result table on which the cursor operates. See Declaring a rowset cursor.
  2. Execute an OPEN CURSOR to make the cursor available to the application. See Opening a rowset cursor.
  3. Specify what the program is to do when all rows have been retrieved. See Specifying the action that the rowset 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 rowset cursor.
  5. Execute a CLOSE CURSOR statement to make the cursor unavailable to the application. See Closing a rowset cursor.

Results

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