MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Effect of Abend on cursors with hold for option

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
bidpar
Beginner


Joined: 08 Jan 2003
Posts: 28
Topics: 4
Location: india

PostPosted: Mon May 19, 2003 4:47 am    Post subject: Effect of Abend on cursors with hold for option Reply with quote

Hi
1) Let's assume I define a cursor with hold option and the program abends.If I do a restart can I be a able to fetch the next row ?
I was thinking at abend time all the cursors are automatically closed by DB2 as the thread ends. The bookmgr tells 'If the program abends, the cursor position is lost; to prepare for restart, your program must reposition the cursor' . Does this mean we need not open the cursor again just need to reposition by fetching multiple times?

2) Does DB2 automatically rollsback data in case of an abend ?

Thanks
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Mon May 19, 2003 5:02 am    Post subject: Reply with quote

bidpar,

To answer you first question better, let us assume that you have defined the cursor as follows.

Code:

DECLARE XYZ CURSOR FOR
SELECT COL1,COL2
 FROM TBL
WHERE KEY > :W-HOST-KEY


Initially you will move low-values to w-host-key if you are processing every record in the table. At the time of checkpoint you will save the key in check point area.

During restart, you will move the saved key value to w-host-key and after the open and fetch of the cursor you will have the next record.

2. Yes db2 automatically does the rollback in case of abend.


Hope this helps...

cheers

kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
bidpar
Beginner


Joined: 08 Jan 2003
Posts: 28
Topics: 4
Location: india

PostPosted: Mon May 19, 2003 5:19 am    Post subject: Reply with quote

Kolusu
That's how we code our program to make it restartable in case of an abend. But somebody told me the cursor remain open even if it abends if it is defined with hold for option. So I was little confused. That's why I asked the question. From your answer it looks like the cursor will close anyway.

Thanks for your answer.
Back to top
View user's profile Send private message
vspangtey
Beginner


Joined: 13 Jun 2003
Posts: 7
Topics: 3

PostPosted: Tue Jun 17, 2003 4:24 am    Post subject: Reply with quote

Hi Bidpar,

We generally use HOLD option for COMMIT statement. Coz if u use COMMIT without HOLD option it will automatically close the CURSOR. In case of abend u will lost the cursor details but the data will be commmited in case of using COMMIT statement otherwise it will ROLLBACK automatically. CURSOR won't remain open in case of abend even if u are using HOLD option.
You can handle the repositioning of CURSOR in your cobol program. To serve the purpose, u should DECLARE cursor with ORDERBY option. There must be a driver or unique key on which u will be retrieving the data, say account no(uniue for the table). U can include the condition of ORDERBY account no. in the declare statement which will select the rows with increasing/decreasing account number.
And then everytime u use COMMIT u can store that particular account number to a another table or to a file. Generally for a particular system people define a separate table for storing the driving/unique variable. what they do is set an indicator for succesful completion of the program. In our program u can check this particular indicator to check whether the previous run was succesful or an abend occcured.
And as KOLUSU has written u also have to use WHERE KEY > :W-HOST-KEY where W-HOST-KEY will have the value of the particular Account number for which the last COMMIT has occured just before the Abend. It will reposition ur cursor as it will only fetch the uncommited data.
I hope now all ur doubts are clear. Please let me know if u still need some more information.

Regards,
Vineet.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group