Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 Update table without cursor Ron Klop DB2 3 Wed Oct 11, 2017 1:06 pm
No new posts Speed-up/reduce CPU use of code prino PL/I & Assembler 0 Tue Sep 26, 2017 12:05 am
No new posts Return a Non Numeric value from REXX Learncoholic CLIST & REXX 3 Fri Sep 01, 2017 8:33 pm
This topic is locked: you cannot edit posts or make replies. how to code for GDG in Rexx cvnlynn CLIST & REXX 13 Wed Aug 09, 2017 9:13 pm
This topic is locked: you cannot edit posts or make replies. rexx code to create a ps file Bharath Vikraman CLIST & REXX 4 Mon Aug 07, 2017 10:30 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us