Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Why do you want to close a cursor

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Why do you want to close a cursor
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    Post subject:
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    Post subject: Reply to: Closing a Cursor
Reply with quote

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

Senior Member


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

PostPosted: Tue Sep 30, 2008 10:27 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Updating Cursor row withour using FOR... chandan.inst DB2 15 Tue Nov 08, 2016 11:17 am
No new posts Variable for cursor names ravikumar15 DB2 5 Sun Jul 17, 2016 7:08 am
No new posts DB2 Stored Procedure - Dynamic SQL - ... GuyC DB2 2 Wed Feb 17, 2016 5:10 pm
No new posts ISREDIT - Position Cursor on the Comm... Tarique Anwer TSO/ISPF 5 Wed Feb 03, 2016 12:44 pm
No new posts Need a cursor to achieve the below re... sandeep kumar302 DB2 10 Tue Mar 31, 2015 10:52 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us