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

DB2 Cursor in my cobol code


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

New User


Joined: 21 Mar 2006
Posts: 8

PostPosted: Fri Jul 24, 2009 4:56 pm
Reply with quote

Hi,

I have a db2 cursor in my cobol code that fetches some data that needs to be passed to another application. There is a restriction that we cannot send more than say 20 records at a time.

So This program needs to be called again and cursor should start processing from the 21st record in the 2 nd call. Please suggest what would be the most efficient way to do this.
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Fri Jul 24, 2009 7:08 pm
Reply with quote

How are you passing the data to the second program ?

option 1
----------
declare a session table, put all the data from cursor in this table ( use a mass insert instead of cursor ) and let the second program access this table ..

option 2
---------
declare an array in your first program ... store all data from the cursor in this array and at each call pass 20 records downstream ... remember global variables ..

option 3
----------
open the cursor in your first program and let the second program directly fetch from the cursor ... allocate the opened cursor in your second program ...
Back to top
View user's profile Send private message
Srihari Gonugunta

Active User


Joined: 14 Sep 2007
Posts: 295
Location: Singapore

PostPosted: Mon Jul 27, 2009 12:41 pm
Reply with quote

Deepti,
You can use Order by the key and pass the key value of the 20th row again to your program

Your where clause will be

AND Key > key_value
ORDER BY KEY

For the first call key value will be spaces or zero.
Back to top
View user's profile Send private message
Ketan Varhade

Active User


Joined: 29 Jun 2009
Posts: 197
Location: Mumbai

PostPosted: Mon Jul 27, 2009 5:31 pm
Reply with quote

Hi,
I would suggest that you can use the restart logic in the above requirement. Just adding to what Ashimer has said . Dump the complete data in a array and then make a incremental counter and read that array.
For the first time just read the table till 20 rec and then process in the application that you want to do, then we when u are again calling the program again read the table till 20 but do not process that values and start doing this after you encounter the value as 21 .

I hope this will help to solve your query icon_smile.gif

Thanks
Ketan Varhade
Back to top
View user's profile Send private message
deeptik

New User


Joined: 21 Mar 2006
Posts: 8

PostPosted: Tue Jul 28, 2009 9:47 am
Reply with quote

Thanks all, I think implementing the > key value will work for me.
Back to top
View user's profile Send private message
deeptik

New User


Joined: 21 Mar 2006
Posts: 8

PostPosted: Tue Jul 28, 2009 9:54 am
Reply with quote

Sessions table may not be possible as u need the authorityto declare a sessions table and it may not be possible for the third party application to access this table directly.

the 2nd application is not a mainframe one, but it is a third party java/unix interface so option 2 and 3 will not work out.

I am not sure but is it possible to use scrollable cursors to implement this logic ?
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 run rexx code with jcl CLIST & REXX 15
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Compile rexx code with jcl CLIST & REXX 6
Search our Forums:

Back to Top