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
 

 

A cursor within a multi-fetch cursor loop

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
jdeeponline

New User


Joined: 08 Sep 2009
Posts: 27
Location: Charlotte

PostPosted: Thu Mar 06, 2014 9:43 am    Post subject: A cursor within a multi-fetch cursor loop
Reply with quote

Hi,

In a COBOL-DB2 program, I have an existing Multi-fetch Cursor that fetches upto 30 rows from a group of tables (join).

DECLARE ABC CURSOR WITH ROWSET POSITIONING FOR ...

I fetch 30 rows at a time in this program using the cursor.

FETCH NEXT ROWSET FROM ABC FOR 30 ROWS...

I have a requirement where I have to use another cursor within the loop that fetches rows from the above multi-fetch cursor, to retrive some fields from a different row(s) of the same table.

I have taken care of moving the SQLCODEs and SQLERRD(3) values to a working storage so that the new cursor doesn't interfere. But will this new cursor reset the ROWSET pointer when I try to fetch the next set of 30 rows from the multi-fetch cursor?

P.S : The reason why I have to include the new cursor is that I have a specific use case around the new select returning multiple rows. I couldn't use the -811 logic since my program uses "WHENEVER SQLERROR" to force an ABEND.

Any insight would be appreciated.
Back to top
View user's profile Send private message

Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 1736
Location: NY,USA

PostPosted: Fri Mar 07, 2014 12:46 am    Post subject:
Reply with quote

Quote:
I have a requirement where I have to use another cursor within the loop that fetches rows from the above multi-fetch cursor, to retrive some fields from a different row(s) of the same table.


Could you please elaborate on this? What makes you to include that within the same cursor and based on what conditions you will fetch the rows here?


Quote:
But will this new cursor reset the ROWSET pointer when I try to fetch the next set of 30 rows from the multi-fetch cursor?


Why would that be as they are two different cursors with SELECT and did you try executing it?
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 Need DB2 query to fetch previous row ! Chandan1993 DB2 10 Sat Jun 03, 2017 10:43 am
No new posts Testing rerad cursor for status with ... John F Dutcher DB2 8 Fri May 19, 2017 9:35 pm
No new posts Getting -504 Cursor Name GTT-ARTS-CUR... Robin Sulsona DB2 2 Fri Mar 17, 2017 1:43 am
No new posts Release of Adabas Cursor mohitsethi All Other Mainframe Topics 1 Mon Feb 06, 2017 8:36 pm
No new posts Updating Cursor row withour using FOR... chandan.inst DB2 15 Tue Nov 08, 2016 11:17 am


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