DB2 - Banco de dados - CLOSE - www.cadcobol.com.br
The CLOSE statement closes a cursor. If a result table was created when the cursor was opened, that table is destroyed.
This statement can be embedded in an application program or issued interactively. It is an executable statement that cannot be dynamically prepared. When invoked using the command line processor, some options cannot be specified. For more information, refer to Using command line SQL statements and XQuery statements.
Using command line SQL statements and XQuery statements
If a global variable is referenced, the privileges held by the authorization ID of the statement must include one of the following authorities:
DECLARE CURSOR
If a cursor that was originally either RR or RS is reopened after being closed using the WITH RELEASE clause, new locks will be acquired.
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;