Valid in: ESQL
The Close statement closes an open cursor. The cursor_name must have been previously defined in your source file by a declare cursor statement. Once closed, the cursor cannot be used for further processing unless reopened with a second open statement. A commit, rollback, or disconnect statement closes all open cursors.
The Close statement has the following format:
EXEC SQL CLOSE cursor_name
Can be specified using a quoted or unquoted string literal or a host language string variable. If cursor_name is a reserved word, it must be specified in quotes. The cursor name cannot exceed 32 characters.
In an embedded Close statement, a string constant or host language variable can be used to specify the cursor name.
All users are permitted to use this statement.
In the Close statement, closing a cursor does not release the locks held by the cursor. (The locks are released when the transaction is completed.)
The following example illustrates cursor processing from cursor declaration to closing:
exec sql declare c1 cursor for
select ename, jobid
from employee
where jobid = 1000;
...
exec sql open c1;
loop until no more rows;
exec sql fetch c1
into :name, :jobid;
print name, jobid;
end loop;
exec sql close c1;