View previous topic :: View next topic
|
Author |
Message |
Chetan Kumar
New User
Joined: 03 Dec 2012 Posts: 46 Location: India
|
|
|
|
Hi All,
I have a requirement to fetch records from DB2 table and write it to a sequential file. I have thousands of rows in DB2 table, so upon job failure I need to see to that after restart, program has to fetch the next row of last retrieved row.
How can we achieve this, as Fetch is based on where condition I.e we are not retrieving all the rows of a table.
Thanks, |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
If that is your entire requirement, why not just use a DB2 utility?
Even so, how do you feel it may fail, such that you have to code for failure? |
|
Back to top |
|
|
Chetan Kumar
New User
Joined: 03 Dec 2012 Posts: 46 Location: India
|
|
|
|
As I mentioned, I'm not retrieving all the rows of the table. Basically lots of rows has to be retrieved and as we are processing thousands of rows and if the jobs fails, I need to add a logic to retrieve from the next row from the last retrieved upon restart.
I thought, If I write a table key to other table2 each time I retrieve a row from the table1 and write to sequential file.
In this case, I need to update the another table for each write record process. Upon job failure, from the table we can get the key and fetch the next row from the table.
But how to use the key in the query to retrieve and continue retrieving next rows? |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
OK, sticking to your program idea, how do you think the program may fail in the future? How many times a year do you feel it may fail? How long does it run for? And something you'll have to provide yourself, what is the overhead of having information available to "restart" it?
Then you can work out whether, over a 10+ year life, it would be worth having restart capability.
If it is never likely to fail in that time, why build restart? So why would you expect it to fail? |
|
Back to top |
|
|
Chetan Kumar
New User
Joined: 03 Dec 2012 Posts: 46 Location: India
|
|
|
|
I'm just checking for the possibility. |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
|
|
|
|
Just out of curiosity, I ran a job that:
- Checks for the existence of GDG bases
- Creates said bases if they do not exist
- Unloads a table containing about 25,000 rows.
Elapsed time: 2 seconds.
Unless your machine is grossly inferior to mine, or you are doing extremely complex processing to determine (or in addition to determining) what rows to unload, having a restart capability is useless. |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3053 Location: NYC,USA
|
|
|
|
Please refer below link and look for Insensetive scrollable cursor and other options. also you will have an order by in your cursor.
publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/DSNAPH11/2.2.2?DT=20010710165542
Quote: |
I have a requirement to fetch records from DB2 table and write it to a sequential file. I have thousands of rows in DB2 table, so upon job failure I need to see to that after restart, program has to fetch the next row of last retrieved row. |
Checkpoint and restart is used in case you have a Commit in your program. Otherwise a simple select statement doesn't have to be coded with restart logic. Has someone asked you to do that? and for your requirement as Bill said make a use of DB2 Utility unless you have any fancy cobol code. |
|
Back to top |
|
|
|