View previous topic :: View next topic
|
Author |
Message |
ap_mainframes
Active User
Joined: 29 Dec 2005 Posts: 181 Location: Canada
|
|
|
|
Hi,
I am new Db2, searched the manuals but couldnt get the answer ! Hence, this question:
Why do you want to close a cursor ? We have been taught that cursor automatically closes at the end of the program. I have tried this ( without closing the cursor ) and it works perfectly fine for me.
Thx for any help you can provide. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Though what you were taught is technically correct,
most professionals perform the necessary i/o and service calls
to close things that their program opened.
In batch, if you have a sub-module that has been processing a cursor,
and you do not explicitly close the cursor in that module,
the cursor is not closed until the run-unit is finished. If you call the submodule again to process another instance of the cursor, you encounter an error when you attempt to open it the 2nd time - it is open, already.
Closing a cursor releases db2 resources, when you close the cursor.
Same goes for COMMITs. At the end of a run-unit, the ops-system will commit everything for you, if you do not have a program abend.
you should periodically commit read only cursors. |
|
Back to top |
|
|
ap_mainframes
Active User
Joined: 29 Dec 2005 Posts: 181 Location: Canada
|
|
|
|
Thanks ! That answers my question. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Good explanation Dick.
Regards,
- Ad |
|
Back to top |
|
|
|