Entering content frame

OPEN CURSOR statement 

An OPEN CURSOR statement generates the result table defined under the specified name with a DECLARE CURSOR statement.

Syntax

<open_cursor_statement> ::= OPEN <result_table_name>

result_table_name

Explanation

Existing result tables are implicitly deleted when a result table is generated with the same name.

All result tables generated within the current transaction are implicitly deleted at the end of the transaction using the ROLLBACK statement.

All result tables are implicitly deleted at the end of the session using the RELEASE statement. A CLOSE statement can be used to delete them explicitly beforehand.

If the name of a result table is identical with that of a base table, view table (see Table), or a synonym, these tables cannot be accessed as long as the result table exists.

At any given time when a result table is processed, there is a position which may be before the first row, on a row, after the last row or between two rows. After generating the result table, this position is before the first row of the result table.

Depending on the search strategy, either all the rows in the result table are searched when the OPEN CURSOR statement is executed and the result table is physically generated, or each next result table row is searched when a FETCH statement is executed, without being physically stored. This must be considered for the time behavior of open cursor statements and fetch statements.

If the result table is empty, the return code 100 – row not found - is set.

The number of rows in the result table is returned in the SQLCA in the third entry of SQLERRD. If this counter has the value -1, there is at least one result row.

Leaving content frame