CLOSE

From InterBase

Go Up to Statement and Function Reference (Language Reference Guide)


Closes an open cursor. Available in gpre.

 CLOSE <cursor>;
Argument Description

<cursor>

Name of an open cursor

Description: CLOSE terminates the specified cursor, releasing the rows in its active set and any associated system resources. A cursor is a one-way pointer into the ordered set of rows retrieved by the select expression in the DECLARE CURSOR statement. A cursor enables sequential access to retrieved rows in turn and update in place.

There are four related cursor statements:

Stage Statement Purpose

1

DECLARE CURSOR

Declares the cursor; the SELECT statement determines rows retrieved for the cursor.

2

OPEN

Retrieves the rows specified for retrieval with DECLARE ­CURSOR; the resulting rows become the active set of the cursor.

3

FETCH

Retrieves the current row from the active set, starting with the first row; subsequent FETCH statements advance the cursor through the set.

4

CLOSE

Closes the cursor and releases system resources.

FETCH statements cannot be issued against a closed cursor. Until a cursor is closed and reopened, InterBase does not reevaluate values passed to the search conditions. Another user can commit changes to the database while a cursor is open, making the active set different the next time that cursor is reopened.

Note:
In addition to CLOSE, COMMIT and ROLLBACK automatically close all cursors in a transaction.

Example: The following embedded SQL statement closes a cursor:

EXEC SQL
CLOSE BC;

See Also

Advance To: