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
 

 

How to resolve SQL Code = -501 error

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
simha_it

New User


Joined: 05 May 2005
Posts: 30

PostPosted: Tue Nov 17, 2009 4:05 pm    Post subject: How to resolve SQL Code = -501 error
Reply with quote

Hi
I am getting SQLCODE = -501 (ERROR: THE CURSOR IDENTIFIED IN A FETCH OR CLOSE STATEMENT IS NOT OPEN) when I was fetching the next row from a Cursor. Ihave declared a cursor with 'WITH HOLD option and not issuing any commit with in the program.

Please suggest me the solution for this...
Back to top
View user's profile Send private message

dbzTHEdinosauer

Global Moderator


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

PostPosted: Tue Nov 17, 2009 5:56 pm    Post subject:
Reply with quote

you have a bug in the program that causes you to perform a FETCH after you have issued a CLOSE to the cursor.

no doubt about it.
Back to top
View user's profile Send private message
simha_it

New User


Joined: 05 May 2005
Posts: 30

PostPosted: Tue Nov 17, 2009 6:40 pm    Post subject:
Reply with quote

I don't have any Close statement in the processing except at the end of the program. Is it possible, DB2 will issue a Commit internally because of any reasons??
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1278
Location: Belgium

PostPosted: Tue Nov 17, 2009 7:15 pm    Post subject:
Reply with quote

No.

You're not writing pseudo-conversational stuff ?
Do you do an open cursor ?
Have you missed a previous sqlcode and try to fetch again ?
SQLCODES -404, -652, -679, -802, -901, -904, -909, -910, -911, -913, and -952 and maybe some others may close cursors
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Tue Nov 17, 2009 7:16 pm    Post subject:
Reply with quote

Quote:
Is it possible, DB2 will issue a Commit internally because of any reasons??


only when the program exits and control returns to the operating system.

either you are performing the close statement and then are fetching again,
or
you did not open the cursor,
or
your cursor open statement did not receive an sqlcode of 0.

you have a bug....stop trying to find a problem with db2. your problem is in your code....
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1278
Location: Belgium

PostPosted: Tue Nov 17, 2009 7:19 pm    Post subject:
Reply with quote

Quote:
your cursor open statement did not receive an sqlcode of 0.

Damn, missed that one.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Tue Nov 17, 2009 8:02 pm    Post subject:
Reply with quote

Quote:
Damn, missed that one.


Hell, I missed all the others.

the program probably does not check sqlcodes after all sql statements.
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 -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to Capture the Max return code of... anilkumar922 All Other Mainframe Topics 0 Thu Jan 12, 2017 12:02 pm
No new posts OO COBOL compile error Virendra Shambharkar COBOL Programming 3 Tue Jan 10, 2017 6:05 pm
This topic is locked: you cannot edit posts or make replies. Calling REXX code from ISPF panel sanchita dey TSO/ISPF 4 Mon Jan 02, 2017 5:13 pm
No new posts PL/I code tuning/Performance improvement Virendra Shambharkar PL/I & Assembler 4 Mon Dec 05, 2016 11:57 am
No new posts S922 Error yuvan ABENDS & Debugging 3 Fri Dec 02, 2016 6:58 pm


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