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

Cursor result set being updated???


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

Active User


Joined: 13 Jun 2012
Posts: 180
Location: United States

PostPosted: Tue May 28, 2019 10:46 pm
Reply with quote

I have a simple cursor in a COBOL program that I use to select records. As I process the cursor, I may be inserting additional rows into the table (SCISTAT) the cursor is based on. When I insert a row into the SCISTAT table, it is the next record I see in the FETCH. The record count taken in the FETCH routine also reflects these inserted records. We are using DB2 V11.
I have never heard of a cursor dynamically updating the result set, but maybe this is something new?

This is the cursor:

Code:
EXEC SQL                       
    DECLARE FLAGSTAT CURSOR FOR
     SELECT DOC_TYPE,           
            BATCH,             
            DOC_ID,             
            MESSAGE_ID         
      FROM SCISTAT             
     WHERE UPDATE_FLAG = 'C'   
       AND SUSFDATE IS NULL     
END-EXEC.                       
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 2567
Location: NYC,USA

PostPosted: Wed May 29, 2019 12:52 am
Reply with quote

Preliminary, Either look for SENSITIVE/INSENSITIVE attributes of a CURSOR options or add WITH UR in DECLARE and let us know if that solves the problem.
Back to top
View user's profile Send private message
John Poulakos

Active User


Joined: 13 Jun 2012
Posts: 180
Location: United States

PostPosted: Wed May 29, 2019 2:35 am
Reply with quote

Thank you for the suggestions. But, first I really wanted to know if it was possible for the result set to dynamically change?
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 2567
Location: NYC,USA

PostPosted: Wed May 29, 2019 4:05 am
Reply with quote

For that please read the link shared above and look for FIRST DEFAULT OPTION provided( ASENSITIVE )which says the results are unpredictable as you experienced in your case. Look at the open statement as to what happens in the subsequent link, it is very clearly mentioned.

So try make a use of WITH UR if you want consistency in the final result.
Back to top
View user's profile Send private message
John Poulakos

Active User


Joined: 13 Jun 2012
Posts: 180
Location: United States

PostPosted: Thu May 30, 2019 9:58 pm
Reply with quote

Cool. Thanks a lot.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 2567
Location: NYC,USA

PostPosted: Fri May 31, 2019 12:16 am
Reply with quote

You're Welcome!!.
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 Undesired result while joining files. SYNCSORT 3
No new posts Is SQLCODE -811 possible while fetchi... DB2 1
No new posts Restart logic by using cursor name in... DB2 1
No new posts Seeking Resolution for SQKCODE -991 o... DB2 2
No new posts Multiple rows within Cursor when Coun... DB2 14
Search our Forums:

Back to Top