When do cursors get closed?
Cursors can remain open in a program if they are not explicitly closed and not all records are fetched from them and the connection is not closed. In other words:
1. If all records are fetched, then the SQLCODE 100 also triggers a cursor close (regardless of whether the cursor was declared WITH HOLD or not).
2. Similarly, if the connection is closed, then the cursors are automatically closed (again regardless of WITH HOLD or not).
3. If the transaction is rolled back, that also closes open cursors automatically (regardless of WITH HOLD or not).
4. If the transaction is committed, that also closes open cursors automatically (unless declared WITH HOLD).
So, if a program opens many WITH HOLD cursors and forgets to close connections, it is possible for these cursors to hang around.
1. If all records are fetched, then the SQLCODE 100 also triggers a cursor close (regardless of whether the cursor was declared WITH HOLD or not).
2. Similarly, if the connection is closed, then the cursors are automatically closed (again regardless of WITH HOLD or not).
3. If the transaction is rolled back, that also closes open cursors automatically (regardless of WITH HOLD or not).
4. If the transaction is committed, that also closes open cursors automatically (unless declared WITH HOLD).
So, if a program opens many WITH HOLD cursors and forgets to close connections, it is possible for these cursors to hang around.

0 Comments:
Post a Comment
<< Home