7.6.15. CLOSE

Used for

Closing a declared cursor

Available in

PSQL

Syntax

  1. CLOSE cursorname
Table 92. CLOSE Statement Parameter
ArgumentDescription

cursorname

Cursor name. A cursor with this name must be previously declared with a DECLARE CURSOR statement and opened by an OPEN statement

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.

Example

Using the CLOSE statement:

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

See also

DECLARE CURSOR, OPEN, FETCH