Step 2: Opening the cursor

 

To begin processing the rows of the result table, issue the OPEN statement.

When your program issues the OPEN statement, SQL processes the select-statement within the DECLARE CURSOR statement to identify a set of rows, called a result table, using the current value of any host variables specified in the select-statement. A result table can contain zero, one, or many rows, depending on the extent to which the search condition is satisfied. The OPEN statement looks like this:

EXEC SQL  OPEN cursor-name END-EXEC.

 

Parent topic:

Examples: Using a cursor