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
 

 

Restart Batch DB2 Pgm @ Abend - After The Last Commit.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
shitij

New User


Joined: 09 Sep 2005
Posts: 31
Location: Delhi

PostPosted: Wed Dec 05, 2007 11:08 pm    Post subject: Restart Batch DB2 Pgm @ Abend - After The Last Commit.
Reply with quote

Hi,

I would like to know what is/are the method(s) by which we can start the batch DB2 pgm. which has abended...after the last commit (eg if I commit after every 1000th insert - and it abends at 1002nd insert).

I mean how will the program know that it has to be restarted after/from the last commit point i.e it has to start inserting from 1001st record of the file.

Could someone please give me an example - A code snippet will do.


Thanks,
Shitij
Back to top
View user's profile Send private message

stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Wed Dec 05, 2007 11:30 pm    Post subject:
Reply with quote

Are you looking for someway for your program to magically know where to restart without any manual intervention in the restart process? Are you doing any kind of tracking to know where the last commit happened or are you just looking at job output? If you have tracking, like writing the record number of the last commit to a file or job log, you could use a parm as input to your program telling it what record the inserts should restart on.


Very Bad:
You could check every record you want to insert for existence with a SELECT with a full WHERE on the record before executing an INSERT. Note that this is very inefficient because if it is a clean run you would be doing many unneeded SELECTs.
Back to top
View user's profile Send private message
anjani shanker

New User


Joined: 26 Jan 2007
Posts: 37
Location: USA

PostPosted: Wed Dec 05, 2007 11:51 pm    Post subject:
Reply with quote

Hi,

Why dont you try a hand with Multi Row fetching.Your task would become easier.In this you have facility to Diagnose for errors as well.


Anjani..
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: Thu Dec 06, 2007 12:40 am    Post subject:
Reply with quote

Hello Anjani and welcome to the forums,

How does multi-row fetching provide an easier restart?

Shitij,
Quote:
Could someone please give me an example - A code snippet will do.
Restart/recovery processing should cover an application or an entire database environment. Restarts should not be some "put together" stuff - it needs to be planned at higher than the program level. There are no generic snippets.

Your organization must decide how restarts will be handled. There is usually much more to a restart than merely processing the correct database rows. If this is some school assignment, you may be able to use some incomplete restart process, but if this is a business requirement, you need to learn more about what is necessary.
Back to top
View user's profile Send private message
shitij

New User


Joined: 09 Sep 2005
Posts: 31
Location: Delhi

PostPosted: Thu Dec 06, 2007 1:03 am    Post subject: Reply to: Restart Batch DB2 Pgm @ Abend - After The Last Com
Reply with quote

Thanks Stodolas/Anjani/Dick for your reply,

I know my question is not that generic (I have tried to search this topic in previous posts also).

Currently what we do is :

Say insertion in the master table is going on and it abends during the process, we can check the sysout to find out how many records inserted (it commits after every 1000th insert) and we clean up the master table of these inserted records before re-starting the job again.

I liked the idea where if we can pass the value/figure (of data inserted) through the PARM we will be able to tell the program from where it should start, but - In that case do I have to make my program logic in such a way that it skips the number of Detail records which are given in the PARM value?

Eg:-

PARM='2000 '

...Is it that I read (and insert) records after the first 2000 detail records - as the first 2000 are already inserted or I can use some other logic?

Thanks,
Shitij
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: Thu Dec 06, 2007 1:13 am    Post subject:
Reply with quote

Hello,

If the only ting the program does is read qsam input and insert database rows, you can do what you want with the parm.

If the program does anything else (writes some kind of output file(s), accumulates any totals for use in reporting or some eoj database summaries, creates any report(s), you will have to include code to re-sync all of these operations.

With the extremely faster processors and database engines in use today, many places do not incorporate restart logic as it is easier and faster to let the updates automatically back out when the process abends and re-run from the beginning. Keep in mind that the more complex the restart, the likelier there will be errors committed which will waste even more time getting the system back to where it needs to be.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10231
Location: italy

PostPosted: Thu Dec 06, 2007 1:17 am    Post subject: Reply to: Restart Batch DB2 Pgm @ Abend - After The Last Com
Reply with quote

Usually in well eshtablished checkpoint restart environment there is
a data base with the info about the running processes/programs
the key is some assigned id, and it will contain all the info needed for the restart

a sample logic would be ...

read the table...
if no record found ... start from the beginning..

if a record is there fill from the checkpoint record all the program variables
which change as the program proceeds

at the specified frequency
update the table and commit ..

if anything happens and the environment is set up the proper way.
the restart will be completely transparent..

for VERY CRITICAL applications also the syouts should be tables
so there will not be any duplicate records , and a stupid select will print everything at the proper time
Back to top
View user's profile Send private message
Aniyaa

New User


Joined: 07 Dec 2007
Posts: 26
Location: Bangalore

PostPosted: Mon Dec 10, 2007 6:02 pm    Post subject: Reply to: Restart Batch DB2 Pgm @ Abend - After The Last Com
Reply with quote

Hi , the restart logic in short is given below.

things to do before abend
populate the last record number key after the commit into an abend file.

things to do after the abend
read from the abend file.
populate the key-field
read in-rec file (using the key field)
update into the table

This is basically what is checkpoint restarting
Please correct me if I am incorrect
Back to top
View user's profile Send private message
TG Murphy

Active User


Joined: 23 Mar 2007
Posts: 149
Location: Ottawa Canada

PostPosted: Tue Dec 11, 2007 2:51 am    Post subject:
Reply with quote

Enrico says it well. One thing to add is this.

Just before your program terminates you must update your RESTART table to note the fact that your job ended successfully. That way - the next time the job executes it will know that it should start in FIRSTRUN mode as opposed to RESTART mode.

Your RESTART table could be defined with the following columns:

Job name (KEY field 1)
Step Name (KEY field 2)
Main line Program ID
VARCHAR(1000) to hold your counters and key values.

We use a 3rd party package to make our sequential files behave like DB2 tables with respect to Commits, Rollbacks and abends.

Other places that don't have 3rd party packages use GDGs instead of sequential files. Everytime they commit, they close the file and open a new generation. When the job terminates all the generations are consolidated back into a single output file.

I could go on and on here - big topic...
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 MIPS/CPU consumption reduction in Batch vishwakotin DFSORT/ICETOOL 4 Sat Mar 18, 2017 5:46 pm
No new posts IMS region inactive - User abend code... gthmrj IMS DB/DC 5 Tue Mar 07, 2017 12:29 pm
No new posts How does a called pgm know if its cal... Graeme Westerman COBOL Programming 4 Tue Nov 29, 2016 9:25 pm
No new posts IMS BMP program causes 878 system abend Artemk IMS DB/DC 7 Tue Nov 22, 2016 8:26 pm
This topic is locked: you cannot edit posts or make replies. MIPS reduction for Batch job Virendra Shambharkar All Other Mainframe Topics 8 Mon Nov 07, 2016 4:02 pm


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