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

Problem on CURSORS.


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

New User


Joined: 30 Aug 2005
Posts: 3

PostPosted: Tue Aug 30, 2005 7:36 pm
Reply with quote

Hi All,

My Problem.
--------------

I have one DB2 Table(ex. Employee).

I want to create a Cursor it retrieve 10 records only at a time.
i execute it 2nd time, then it fetch from 11 to 20 records.
i execute it 3rd time, then it fetch from 21 to 30 records.
i execute it 4th time, then it fetch from 31 to 40 records.

like this way i fetch 100 records.

This query i will include in the sub-program. The main program calls the subprogram 10 times , so that i can retrieve 100 records.

Regards,
Srinivas.a
Back to top
View user's profile Send private message
krishnaiahc

New User


Joined: 31 Aug 2005
Posts: 21

PostPosted: Wed Aug 31, 2005 5:14 pm
Reply with quote

Hai,

By using Fetch first n rows only.... I think it will help for requirement..

Regards,
Krishna
Back to top
View user's profile Send private message
ovreddy

Active User


Joined: 06 Dec 2004
Posts: 211
Location: Keane Inc., Minneapolis USA.

PostPosted: Mon Sep 05, 2005 4:18 pm
Reply with quote

Hi Srinivas,

Your requirement looks like a Scroll logic in an Online screen i.e. in a CICS+DB2 Program. To fulfill your requirement you need to do 2 things.

- Write a DB2 Cursor Query which is generic and fetches next 10 records to the given Variable.

Eg: SELECT COL1,COL2,Col3... INTO :HV-VAR1,:HV-VAR2,:HV-VAR3,.... WHERE MBNISS>:HV-MBNISS FETCH FIRST 10 ROWS ONLY;

- I hopes the HV-MBNISS will contain the last record fetched from the table. It means 10th record in first case, 20th in second ran .....
- If you want to exit and restart the program again and again (Other than online scrolling logic) You need to write last MBNISS to a file before closing the cursor. And when you start the program next time you read that file and execute this query.

I know this is not looking clear for you. But I expect you to come up with more details about your case.

Thanks,
Reddy.
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 Map Vols and Problem Dataset All Other Mainframe Topics 2
No new posts z/vm installation problem All Other Mainframe Topics 0
No new posts Job scheduling problem. JCL & VSAM 9
No new posts Problem with IFTHEN=(WHEN=GROUP,BEGIN... DFSORT/ICETOOL 5
No new posts Need to add field to copybook, proble... COBOL Programming 14
Search our Forums:

Back to Top