The CLOSE statement closes a cursor.
Embedded Mode P |
Dynamic Mode |
Interactive Mode |
cursor_identifier |
A valid cursor identifier which identifies the cursor to be closed. |
host_variable_specification |
A valid single host variable specification. It must have been defined in the application program according to the host language rules. |
The CLOSE statement closes a cursor. It releases resources allocated by an OPEN cursor statement. The value of the host variable must be a valid cursor identifier. A host variable can be used as cursor identifier only if the cursor is a dynamically declared cursor.
The cursor to be closed must have been opened.
All cursors opened within a transaction are automatically closed by a COMMIT or ROLLBACK statement. The associated DECLARE CURSOR statement must precede the CLOSE statement in the host program.
The CLOSE statement does not have to be preceded by the associated DECLARE CURSOR statement. It may appear anywhere in the host program, even in another compilation unit.
Example
The following example closes cursor1.
CLOSE cursor1;