Previous Topic: DescriptionNext Topic: Effect of Temporary Tables


Processing

All cursors in a program are in the closed state when:

  1. The program is initiated.
  2. The program initiates a new unit of recovery by executing a COMMIT or ROLLBACK operation.

    Note: Unless the WITH HOLD option has been used in the DECLARE CURSOR statement, a new unit of work is started for the application process.

A cursor can also be in the closed state because:

  1. A CLOSE statement was executed.
  2. An error was detected that made the position of the cursor unpredictable.

The only way to change the state of a cursor from closed to open is to execute an OPEN statement.

To retrieve rows from the result table of a cursor, you must execute a FETCH statement when the cursor is open.