5. Working with a Database : How You Can Access a Database with Standard SQL Statements : How You Can Use Cursors to Access the Database : How You Can Close a Cursor
 
Share this page                  
How You Can Close a Cursor
When the program has processed all the required rows in the result table, close the cursor. Closing a cursor:
Sets the cursor's State attribute to CS_CLOSED
Makes changes visible to the rest of the program (if the cursor was a deferred update cursor)
Releases any locks held by the select statement associated with the cursor (if autocommit is on)
For a description of autocommit, see How Running with Autocommit On Works (see How Running with Autocommit On Works).
If you reopen a closed cursor, the cursor is repositioned at the top of the result table.
The following statement provides an example of closing a cursor:
close cust_cursor;
In addition to being closed explicitly by the close statement, cursors are also closed implicitly when the variable representing them goes out of scope. For example, if the cursor object is referenced by a variable declared locally to a frame and the frame closes without explicitly closing the cursor object, the cursor object is closed automatically.