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
 

 

DB2 Cursor in my cobol code

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: DB2 Cursor in my cobol code
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    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 Testing rerad cursor for status with ... John F Dutcher DB2 8 Fri May 19, 2017 9:35 pm
No new posts Job failing with USER = 4093 REASON C... Pradeepa S ABENDS & Debugging 1 Wed May 17, 2017 3:35 pm
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm
No new posts IMS T-Pipe queue counts in a COBOL Pr... Siva NKK Kothamasu IMS DB/DC 0 Tue May 09, 2017 6:31 pm
No new posts COBOL Code Parsers and Lineage Establ... balimanja COBOL Programming 2 Tue May 02, 2017 3:30 am


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