The CLOSE statement closes a cursor. If a result table was created when the cursor was opened, that table is destroyed.
Invocation
This statement can be embedded in an application program or issued interactively. It is an executable statement that cannot be dynamically prepared.
Authorization
None required. See DECLARE CURSOR for the authorization required to use a cursor.
Syntax
>>-CLOSE--cursor-name----+---------------+--------------------->< '-WITH RELEASE--'
Description
Notes
If a cursor that was originally either RR or RS is reopened after being closed using the WITH RELEASE clause, then new read locks will be acquired.
Example
A cursor is used to fetch one row at a time into the C program variables dnum, dname, and mnum. Finally, the cursor is closed. If the cursor is reopened, it is again located at the beginning of the rows to be fetched.
EXEC SQL DECLARE C1 CURSOR FOR SELECT DEPTNO, DEPTNAME, MGRNO FROM TDEPT WHERE ADMRDEPT = 'A00'; EXEC SQL OPEN C1; while (SQLCODE==0) { . EXEC SQL FETCH C1 INTO :dnum, :dname, :mnum; . . } EXEC SQL CLOSE C1;