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 

DB2 - delay

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


Joined: 15 Dec 2005
Posts: 20
Topics: 9

PostPosted: Thu Dec 29, 2005 3:53 am    Post subject: DB2 - delay Reply with quote

Hi,

Is there a delay command in DB2 ?

Suppose if I have batch DB2 pgm, and if I encounter deadlock then I want to delay for 3 min and then again perform the same statement to avoid deadlock. How is it possible to delay in db2 ?

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


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

PostPosted: Thu Dec 29, 2005 5:45 am    Post subject: Reply with quote

Hema_Manyam,

There is no concept of delay in DB2. However you have a delay funtion in cobol. check this link

http://mvsforums.com/helpboards/viewtopic.php?t=2008&highlight=delay

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Manas Biswal
Intermediate


Joined: 29 Nov 2002
Posts: 382
Topics: 27
Location: Chennai, India

PostPosted: Thu Dec 29, 2005 10:11 am    Post subject: Reply with quote

Hema_Manyam,

There are a lot of different scenarios that you need to consider when handling deadlocks in DB2. Most of the time, you really have no control over deadlocks, and DB2 will automatically rollback one of the transactions involved in a deadlock.
DB2 deadlocks should be avoided and you can do various things both at an application level and at the database configuration level to minimise deadlocks. But as far as "handling" deadlocks is concerned, DB2 does most of the work and the application has limited control over it.

When DB2 detects a deadlock, two scenarios can potentially happen to your application -
1. DB2 attempts to rollback the SQL and the UOW of the current application. If the rollback is successful, then the application abends with a SQLCODE of -911. You have to redo the transaction or the job again. You cannot retry the SQL within the same transaction or job.
2. If the attempt to rollback fails, then DB2 throws the -913 SQL exception, which you can capture from within your application and retry the transaction (after the delay that you mentioned).

Again, the above two scenrios depend on the interfacing application. The behavior id different for TSO BATCH, DLI Batch, IMS and CICS applications accessing DB2.
Sometimes, your application can control and resume/retry after a deadlock and sometimes it can't. I would suggest that you go through the DB2 for Z/OS manual before coding for deadlocks.
You can use the below as a starting point -
http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=/com.ibm.db2.doc.apsg/bjnqmstr283.htm

HTH....Regards,
Manas
_________________
There is no path to peace. Peace is the path.
- Mahatma Gandhi (1869-1948)
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
a_seshu
Beginner


Joined: 30 Sep 2004
Posts: 16
Topics: 4
Location: Chennai

PostPosted: Fri Dec 30, 2005 12:40 pm    Post subject: Reply with quote

Hema_Manyam

Think this way.....

Your program encountered a deadlock at a particular point... You end up getting an sql code of -911 or -913. All the work done in your program in that LUW (Logical Unit of Work) would have been rolled back by then. Now do you think there is any advantage doing a delay and reattempting the same operation???

Take this example

You have a sequence of three updates to perform a process for an update.

Code:
Update Table1
Update Table2
Update Table3


Now Update Table1 and Update Table2 completed successfully. Now for updating Table3 u had a deadlock. Now when the control returns back to the program from DB2, you will end up with an SQL Code of -911/-913 and remember DB2 rolled back the updates for Table1 and Table2. Now even if you delay and update Table3, you have lost the updates for Table1 and Table2.

If you dont have any updates/inserts/deletes (write operations to DB2) in a LUW, you can proceed with your approach but if you have any thing like that, the delay logic wont work.

In those cases, I would suggest abend the program at that point and restart from the abending record.
_________________
I dont think I would ever stop learning. - Seshu.
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger
Hema_Manyam
Beginner


Joined: 15 Dec 2005
Posts: 20
Topics: 9

PostPosted: Sat Dec 31, 2005 12:52 am    Post subject: Reply with quote

Thanks Manas & a_seshu. I realise, I am out of my mind when I am posting this question. Here is the reason why it happened.

Currently I am also working in IDMS, here when deadlock happens we close all files, rebind the areas and then use delay command to try again. Hence I was thinking in that mode and have raised this query. Later I realised that it is not possible to do db2 bind inside the program similar to IDMS.

Thanks guys for your detailed explanation.

Regards,
Hema.
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