Firebird 2.0
PSQL Reference
Manual

VARIABLE DECLARATIONS – CURSOR

Purpose

Use the cursor variable declaration syntax to define a cursor that can executed and processed in the PSQL program.

Syntax

<cursor_declaration> ::=
   DECLARE [VARIABLE] <cursor_name>
   CURSOR FOR ( <select_stmt> );

<cursor_name> ::=   <identifier>


Element
Description
cursor_name
Name of the cursor
select_stmt

A select statement as defined in the SQL Reference manual

Semantics

Cursor names are required to be unique in the given context. Within a single PSQL program cursor declarations must use unique names, and they must also not conflict with the name of a cursor that is "named", via the AS CURSOR clause in a FOR SELECT statement. However, a cursor can share its name with a scalar variable in the same PSQL program, since the operations available to each are different.

When a cursor is open, updates and deletes using the WHERE CURRENT OF clause can be used to affect the current row of the cursor, so called “positioned” updates and deletes.

All cursors which were not explicitly closed will be closed automatically on exit from the current PSQL program.

Examples

The following declaration defines a local cursor named “C”

DECLARE C CURSOR FOR
   ( SELECT RDB$RELATION_NAME FROM RDB$RELATIONS );


See also

OPEN statement, FETCH statement, CLOSE statement, WHERE CURRENT OF clause in the SQL Reference Manual.


previous page goto index next page

Legal information