Firebird 2.0
PSQL Reference
Manual

OPEN CURSOR STATEMENT

Pupose

Use the OPEN statement to open a local cursor.

Syntax

<open_stmt> ::=
   OPEN <cursor_name>;

<cursor_name> ::=   <identifier>


Element
Description
cursor_name
Name of a local cursor

Semantics

The OPEN statement opens a local cursor. Opening a cursor means that the associated query is executed and the that the result set is kept available for subsequent processing by the FETCH statement. The cursor must have been declared in the declarations section of the PSQL program.

Attempts to open a cursor that is already open, or attempts to open a named FOR SELECT cursor will fail and generate a run-time exception. All cursors which were not explicitly closed will be closed automatically on exit from the current PSQL program.

Examples

The following PSQL program opens a cursor, fetches a single row and then closes the cursor:

DECLARE RNAME CHAR(31);
DECLARE C CURSOR FOR
   (SELECT RDB$RELATION_NAME FROM RDB$RELATIONS);
BEGIN
   OPEN C;
   FETCH C INTO :RNAME;
   CLOSE C;
END


See also

CLOSE statement, FETCH statement.


previous page goto index next page

Legal information