Closing a declared cursor

    Available in

    PSQL

    A CLOSE statement closes an open cursor. Any cursors that are still open will be automatically closed after the module code completes execution. Only a cursor that was declared with DECLARE CURSOR can be closed with a CLOSE statement.

    Using the CLOSE statement:

    1. SET TERM ^;
    2. RETURNS (
    3. RNAME CHAR(31)
    4. )
    5. DECLARE C CURSOR FOR (
    6. SELECT RDB$RELATION_NAME
    7. FROM RDB$RELATIONS);
    8. BEGIN
    9. OPEN C;
    10. WHILE (1 = 1) DO
    11. FETCH C INTO :RNAME;
    12. IF (ROW_COUNT = 0) THEN
    13. LEAVE;
    14. SUSPEND;
    15. END
    16. CLOSE C;

    See also

    , OPEN,