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

Cursor - Not getting the return code +100


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

New User


Joined: 29 Mar 2006
Posts: 59
Location: Montreal

PostPosted: Tue Jun 10, 2008 5:57 pm
Reply with quote

Hi All,

I have a cursor in my program,

Fetch operation is not throwing the SQLCODE +100, when it reaches the end of the table, instead it is fetching the first row again, what may be the reason, if anyone knows, please let me know..

cursor defnitiion:
EXEC SQL
DECLARE VQ18-CSR CURSOR FOR
SELECT A.WK_TEL_NO,
A.DUE_DT
FROM VQ1801 A, VS05 B

WHERE ( A.DUE_DT >= :WS-DUE-DATE ) OR
( A.SODB_INTRNL_KY = B.SODB_INTRNL_KY
AND
B.DUE_DT_RC NOT IN (' ', 'OK' ))
FOR FETCH ONLY
END-EXEC.

PERFORM OPEN-CURSOR.
PERFORM UNTIL NO-MORE-ORDERS
PERFORM 2020-FETCH-CSR THRU 2020-EXIT
END-PERFORM

2020-FETCH-CSR.
EXEC SQL
FETCH VQ18-CSR
INTO :BDVQ18-WK-TEL-NO,
:BDVQ18-DUE-DT
END-EXEC
IF SQLCODE = 0
CONTINUE
ELSE
IF SQLCODE = +100
SET NO-MORE-ORDERS TO TRUE
ELSE
CALL ABEND ROUTINE
END-IF.
END-IF

I am not get the SQL code +100, after fetching all the records, instead it is fetching the first record again, please let me know the reason if anybody knows

Thannks and Regards
Venkat
Back to top
View user's profile Send private message
nuthan

Active User


Joined: 26 Sep 2005
Posts: 146
Location: Bangalore

PostPosted: Tue Jun 10, 2008 7:05 pm
Reply with quote

Hi,
Can you please check whether you have coded any where else the statement "PERFORM 2020-FETCH-CSR THRU 2020-EXIT" apart from the above mentioned Inline perform.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Jun 10, 2008 7:09 pm
Reply with quote

well this is crap:
Code:

IF SQLCODE = 0
    CONTINUE
ELSE
     IF SQLCODE = +100
        SET NO-MORE-ORDERS TO TRUE
     ELSE
         CALL ABEND ROUTINE
     END-IF.
END-IF


what else are you doing in your program? are you doing anything that would reposition the cursor pointer?

and performing thru exits is also bad code.

don't see a close cursor. what else is dropping thru.

how do you know that it is starting again? have you spufi'd this sql to see how many rows the cursor should return?
Back to top
View user's profile Send private message
the_gautam

Active User


Joined: 05 Jun 2005
Posts: 165
Location: Bangalore

PostPosted: Wed Jun 11, 2008 8:14 am
Reply with quote

The structure of your program is not so clear with the data provided.
Can you be more detailed...
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Wed Jun 11, 2008 4:09 pm
Reply with quote

There appears no problem after looking into your code ...

If you could try and answer dick's questions i think you shud be able to find out the error ...

change ur code for better readability ... and make sure your flag is not set on before the perform ...

Code:



PERFORM OPEN-CURSOR.
PERFORM 2020-FETCH-CSR UNTIL NO-MORE-ORDERS
PERFORM CLOSE-CURSOR

2020-FETCH-CSR.

EXEC SQL
FETCH VQ18-CSR
INTO :BDVQ18-WK-TEL-NO,
:BDVQ18-DUE-DT
END-EXEC

EVALUATE SQLCODE

WHEN 0
   CONTINUE
WHEN 100
    SET NO-MORE-ORDERS TO TRUE
WHEN OTHER
  CALL ABEND ROUTINE
END-EVALUATE.

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 run rexx code with jcl CLIST & REXX 15
No new posts Compile rexx code with jcl CLIST & REXX 6
No new posts Return codes-Normal & Abnormal te... JCL & VSAM 7
No new posts REXX code to expand copybook in a cob... CLIST & REXX 2
No new posts VSAM return code 23 - for a Random read COBOL Programming 4
Search our Forums:

Back to Top