The CLOSE command (embedded SQL only) closes a cursor previously opened by a DECLARE CURSOR command. If a temporary table
is created as a result of the cursor, that table is deleted when the cursor is closed.
Invocation
CLOSE is an executable command that can only be embedded in a host language. CLOSE cannot be dynamically prepared.
Authorization
See
Authorization under the
DECLARE CURSOR command topic for the authorization required to use a cursor.
Parameters:
cursor-name:
|
Identifies the cursor opened by a DECLARE CURSOR command.
|
Example:
The following example (in the C language) declares a cursor named
deptemp using the EMPLOYEE table, and then closes the cursor:
EXEC SQL
DECLARE CURSOR deptemp FOR
SELECT * FROM employee
WHERE dept = :deptno
;....
EXEC SQL
CLOSE deptemp;
Note: If the WITH HOLD option is not specified in the declaration of a cursor, then that cursor (when opened) is implicitly closed
when a unit of work is terminated. Performance can be improved, however, by explicitly closing cursors as soon as possible.
A CLOSE command does not necessarily commit or rollback system changes or updates (unless AUTOCOMMIT is on).
Description
A CLOSE command is checked for all syntactical elements. The cursor must have been previously declared relative to the source program line in which CLOSE is encountered.