Alpha

These pages are built from main, turborel 0.0.0. Anything may change from one build to the next: SQL, API, protocol and files alike.

CLOSE

Statements

NAME

CLOSE: close a cursor (in a program)

SYNOPSIS

<close statement> ::= CLOSE <cursor name>

<dynamic close statement> ::= CLOSE <extended cursor name>

The <extended cursor name> is ALLOCATE CURSOR's.

DESCRIPTION

CLOSE ends an open cursor: its rows are let go, and it may be opened again, its query run anew. The transaction goes on. COMMIT and ROLLBACK close every open cursor of the transaction.

Out of a compound statement, CLOSE runs only in a program that embeds turborel: see DECLARE CURSOR.

A cursor a compound statement declares (BEGIN) is closed by this statement within it, in a routine's body, a trigger's action or a statement run directly. Its name is the compound statement's own, in scope there alone, and the cursor is destroyed as the compound statement ends.

RULES

  1. The cursor is open.

PRIVILEGES

None.

ERRORS

SQLSTATE SQLCODE When
2A000 -103 No cursor of the name is declared
24000 -501 The cursor is not open
34000 -921 No cursor of the extended name is allocated

EXAMPLES

Of the open cursor C of FETCH:

CLOSE C     Success
CLOSE C     -501 (24000): cursor C is not open [X3.135-1986 §8.1 GR1]

Of a parameter CUR holding NONE, the name of no cursor allocated:

CLOSE CUR   -921 (34000): no cursor 'NONE' is allocated [ISO/IEC 9075:1992 §17.16 SR2]

STANDARD

ISO/IEC 9075:1992 §13.4, and of an extended cursor name §17.16; X3.135-1986 §8.1. A local cursor's is ISO/IEC 9075-4:2006 draft §12.4, Feature P002.

SEE ALSO

DECLARE CURSOR, OPEN, FETCH