Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules*| Site Map | Mainframe CD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search Memberlist Usergroups Profile Log in to check your private messages Log in
 
Problem on CURSORS.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
Author Message
appala_srinivas

New User


Joined: 30 Aug 2005
Posts: 3

PostPosted: Tue Aug 30, 2005 7:36 pm    Post subject: Problem on CURSORS.
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
References
krishnaiahc

New User


Joined: 31 Aug 2005
Posts: 14

PostPosted: Wed Aug 31, 2005 5:14 pm    Post subject:
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: 200
Location: Keane India Ltd., Hyderabad

PostPosted: Mon Sep 05, 2005 4:18 pm    Post subject:
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
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1