IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Why do you want to close a cursor


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ap_mainframes

Active User


Joined: 29 Dec 2005
Posts: 181
Location: Canada

PostPosted: Mon Sep 29, 2008 6:45 pm
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Sep 29, 2008 7:57 pm
Reply with quote

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
View user's profile Send private message
ap_mainframes

Active User


Joined: 29 Dec 2005
Posts: 181
Location: Canada

PostPosted: Mon Sep 29, 2008 8:05 pm
Reply with quote

Thanks ! That answers my question.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Tue Sep 30, 2008 10:27 am
Reply with quote

Good explanation Dick.

Regards,
- Ad
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Is there a way to close VSAM files us... CICS 8
No new posts IGZ0035S THERE WAS AN UNSUCCESSFUL OP... COBOL Programming 3
No new posts Is SQLCODE -811 possible while fetchi... DB2 1
No new posts Restart logic by using cursor name in... DB2 1
No new posts Seeking Resolution for SQKCODE -991 o... DB2 2
Search our Forums:

Back to Top