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.
Joined: 06 Dec 2004 Posts: 211 Location: Keane Inc., Minneapolis USA.
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.