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
 

 

DB2 commits with 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: Tue May 12, 2009 2:35 am    Post subject: DB2 commits with Cursor
Reply with quote

Hello,

In my program, I have got a cursor. I do some processing based on the record it receive from cursor.

I need to commit ( manually ) in my program. Can some one tell me what all things I need to do with the cursor ? Like, do I need to repositon the cursor etc ?

Thanks for all the help anyone can provide.
Back to top
View user's profile Send private message

Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1238
Location: Richfield, MN, USA

PostPosted: Tue May 12, 2009 2:52 am    Post subject:
Reply with quote

If you use the WITH HOLD option of your OPEN CURSOR, it will remain open across COMMITs, otherwise a COMMIT will close it.
Back to top
View user's profile Send private message
ap_mainframes

Active User


Joined: 29 Dec 2005
Posts: 181
Location: Canada

PostPosted: Tue May 12, 2009 7:53 am    Post subject:
Reply with quote

Thanks..Do I need to worry about repositioning of Cursor ?
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1238
Location: Richfield, MN, USA

PostPosted: Tue May 12, 2009 8:32 am    Post subject:
Reply with quote

Once the cursor is closed, you would need to open it again. Your logic would determine whether or not you need to position the cursor at the desired fetched row.
Back to top
View user's profile Send private message
ap_mainframes

Active User


Joined: 29 Dec 2005
Posts: 181
Location: Canada

PostPosted: Tue May 12, 2009 9:31 am    Post subject:
Reply with quote

ok..but I will use WITH HOLD option so that the cursors are open..then I think I dont have to worry about repositioning..Is my assumption correct ?
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1238
Location: Richfield, MN, USA

PostPosted: Tue May 12, 2009 9:35 am    Post subject:
Reply with quote

Yes.
Back to top
View user's profile Send private message
ap_mainframes

Active User


Joined: 29 Dec 2005
Posts: 181
Location: Canada

PostPosted: Tue May 12, 2009 9:41 am    Post subject:
Reply with quote

Thank you Terry for your help.
Just to summarize my conclusions

I'll use WITH HOLD option in my open cursor. With that the cursor will be open even when commiting in the program. Hence, I dont have to reposition the cursor.

Please correct me if I am incorrect any where...

Once again appreciate your help !
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1238
Location: Richfield, MN, USA

PostPosted: Tue May 12, 2009 9:44 am    Post subject:
Reply with quote

That's about it. For more detailed info see the link at the top of the screen called IBM Manuals.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue May 12, 2009 10:23 am    Post subject:
Reply with quote

Hello,

And to build confidence, create a very small program that is fed specific values to force different "found sets" for different iterations using the cursor. The only reason for the program is to exercise the question cursor and commit.

Do some commits and some without and put displays in the code to track the results.

When you see it work as you understand, it is a great confidence builder icon_smile.gif

If there are any surprises, someone will be here.
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1238
Location: Richfield, MN, USA

PostPosted: Tue May 12, 2009 8:58 pm    Post subject:
Reply with quote

Nothing beats writing little test programs as Dick suggests to better understand how things work.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Tue May 12, 2009 10:03 pm    Post subject:
Reply with quote

I believe there is a work-culture problem here.

Quote:
Nothing beats writing little test programs as Dick suggests to better understand how things work


I fully agree and do it often. But it seems as if most of the posters
not only can not or will not do this -- for what ever reason.
Back to top
View user's profile Send private message
ap_mainframes

Active User


Joined: 29 Dec 2005
Posts: 181
Location: Canada

PostPosted: Wed May 13, 2009 12:47 am    Post subject:
Reply with quote

Alright, it worked for me and the results are fine.

Thks all for all the help.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed May 13, 2009 12:57 am    Post subject: Reply to: DB2 commits with Cursor
Reply with quote

You're welcome.

Good to hear it is working - thanks for letting us know icon_smile.gif

d
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 Introducing Commits to batch programs... Div Grad DB2 10 Tue Apr 07, 2015 7:45 pm


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