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
 

 

Cursor - Not getting the return code +100

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Cursor - Not getting the return code +100
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    Post subject:
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: 6968
Location: porcelain throne

PostPosted: Tue Jun 10, 2008 7:09 pm    Post subject:
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    Post subject:
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    Post subject:
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    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 EXIT or RETURN cvnlynn CLIST & REXX 16 Wed Jul 19, 2017 2:50 am
No new posts UNIT=AFF for Easytrieve code gandikk JCL & VSAM 7 Wed Jul 12, 2017 11:42 pm
No new posts DB2 Program abending without giving a... rahulgarg14 DB2 7 Mon May 29, 2017 8:10 pm
No new posts Testing rerad cursor for status with ... John F Dutcher DB2 8 Fri May 19, 2017 9:35 pm
No new posts Job failing with USER = 4093 REASON C... Pradeepa S ABENDS & Debugging 1 Wed May 17, 2017 3:35 pm


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