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

Regarding Cursor withhold option


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

New User


Joined: 20 Jun 2005
Posts: 26
Location: Hyderabad

PostPosted: Fri Sep 30, 2005 12:21 pm
Reply with quote

Hi ,

Can any one help me out regarding
Cursor with hold option
How does it work while using Commit operation
and For RollBack operation.
Syntax please......
Back to top
View user's profile Send private message
ikumar

New User


Joined: 02 Aug 2005
Posts: 81

PostPosted: Fri Sep 30, 2005 12:48 pm
Reply with quote

If you want to hold any cursor, you should have WITH HOLD option in declare cursor.
The syntax is:
EXEC SQL
DECLARE cursor-nameCURSOR WITH HOLD FOR
SELECT ....
END-EXEC.

Suppose in your logic, if you are using commit after certain number of updations/deletions, then cursor will get automatically closed. But you want to retain the cursor till the complete updation process gets over. In that case you have to use WITH HOLD option which prevents your cursor to get closed when commit operation occurs.
Back to top
View user's profile Send private message
nal_satish

New User


Joined: 20 Jun 2005
Posts: 26
Location: Hyderabad

PostPosted: Fri Sep 30, 2005 4:20 pm
Reply with quote

My Question is How does it work for ROLLBACK operation
Back to top
View user's profile Send private message
ikumar

New User


Joined: 02 Aug 2005
Posts: 81

PostPosted: Fri Sep 30, 2005 5:37 pm
Reply with quote

If you issue ROLLBACK, the held cursor will be closed.

Cheers,
Kumar.
Back to top
View user's profile Send private message
ak1972

New User


Joined: 25 Aug 2005
Posts: 7

PostPosted: Sat Oct 01, 2005 4:25 am
Reply with quote

With Hold works only for Commit, does NOT work for rollback - and works only where DB2 is the Transaction manager
Back to top
View user's profile Send private message
nal_satish

New User


Joined: 20 Jun 2005
Posts: 26
Location: Hyderabad

PostPosted: Sat Oct 01, 2005 11:01 am
Reply with quote

Ok thanks For Reply

Could u please Confirm this

Suppose i have 1000 Rows
I have used Cursor With Hold

After Updating 100 Records i have issued Commit -----> first Transaction
so the Cursor points to 101 record for next operation ( if i use with hold option)

after processing some(100 (first)+ 50) fifty more rows some problem encountered so i have issued a roll Back ======> Second Transaction
so the Fifty records processed will be roll backed

So when i try to perform open cursor operation after second Transaction
where it will point it will point to the 101 record or
again back to the initial i.e 1 row

Please Clarify me

Sorry if am casuing some inconvinience.....

Thanks & Regards,
Satish.
Back to top
View user's profile Send private message
ikumar

New User


Joined: 02 Aug 2005
Posts: 81

PostPosted: Sat Oct 01, 2005 1:46 pm
Reply with quote

It starts again from the beginning of the cursor, that is, from the first row onwards....you should have some kind of restrat logic in your application program to start your processing again from the 101th row.

search the forum for the restart logic, if you need it.

Cheers,
Kumar
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 SCOPE PENDING option -check data DB2 2
No new posts OUTFIL with SAVE option DFSORT/ICETOOL 7
No new posts CICS vs LE: STORAGE option CICS 0
No new posts INSYNC option with same function as I... JCL & VSAM 0
No new posts Option DYNALLOC second parameter. DFSORT/ICETOOL 11
Search our Forums:

Back to Top