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

Cobol - DB2 row retrieval.


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

New User


Joined: 03 Dec 2012
Posts: 46
Location: India

PostPosted: Fri Oct 16, 2015 10:44 am
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Oct 16, 2015 11:31 am
Reply with quote

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
View user's profile Send private message
Chetan Kumar

New User


Joined: 03 Dec 2012
Posts: 46
Location: India

PostPosted: Fri Oct 16, 2015 11:51 am
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Oct 16, 2015 11:56 am
Reply with quote

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
View user's profile Send private message
Chetan Kumar

New User


Joined: 03 Dec 2012
Posts: 46
Location: India

PostPosted: Fri Oct 16, 2015 12:05 pm
Reply with quote

I'm just checking for the possibility.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Fri Oct 16, 2015 10:08 pm
Reply with quote

Just out of curiosity, I ran a job that:
  1. Checks for the existence of GDG bases
  2. Creates said bases if they do not exist
  3. 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
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Sat Oct 17, 2015 12:57 am
Reply with quote

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
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 Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top