DECLARATIONS – CURSOR
Use the cursor variable declaration syntax to
define a cursor that can executed and processed in the PSQL program.
CURSOR FOR (
<cursor_name> ::= <identifier>
Name of the cursor
A select statement as
defined in the SQL Reference manual
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.
The following declaration defines a local cursor
DECLARE C CURSOR FOR
SELECT RDB$RELATION_NAME FROM RDB$RELATIONS );
OPEN statement, FETCH statement, CLOSE statement,
WHERE CURRENT OF clause in the SQL Reference Manual.