View previous topic :: View next topic
|
Author |
Message |
John Poulakos
Active User
Joined: 13 Jun 2012 Posts: 178 Location: United States
|
|
|
|
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 |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3051 Location: NYC,USA
|
|
Back to top |
|
|
John Poulakos
Active User
Joined: 13 Jun 2012 Posts: 178 Location: United States
|
|
|
|
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 |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3051 Location: NYC,USA
|
|
|
|
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 |
|
|
John Poulakos
Active User
Joined: 13 Jun 2012 Posts: 178 Location: United States
|
|
|
|
Cool. Thanks a lot. |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3051 Location: NYC,USA
|
|
|
|
You're Welcome!!. |
|
Back to top |
|
|
|