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
 

 

DB2 SQLCODE -50

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
avinash pandey

New User


Joined: 10 Apr 2008
Posts: 17
Location: Bangalore

PostPosted: Sat May 30, 2009 10:35 am    Post subject: DB2 SQLCODE -50
Reply with quote

I have COBOL+CICS+DB2 program, i am using the cursor to fetch the record from table. But after fetch statment i am getting the SQLCODE -50. I am not able to fine the reason for this sqlcode. Could anybody elaborate me why we get this sqlcode.






Hi! This is your First post in our Forums! So please be sure to 1) Use meaningful and descriptive Topic Title 2) Try to post your query in the relevant forum category 3) Make sure your query is not already posted and solved in our forums, Use the Search facility and avoid Reposts! If you are following the above rules, delete this message and post your query here!
Back to top
View user's profile Send private message

dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sat May 30, 2009 10:45 am    Post subject:
Reply with quote

Hello and welcome to the forum,

I suspect that in addition to having a problem with with the query, there is also a problem presenting the returned sqlcode. The IBM documentation does not list a -50 sqlcode.

How was the -50 determined?
Back to top
View user's profile Send private message
avinash pandey

New User


Joined: 10 Apr 2008
Posts: 17
Location: Bangalore

PostPosted: Sat May 30, 2009 10:51 am    Post subject: Reply to: DB2 SQLCODE -50
Reply with quote

EXEC SQL
002265 FETCH FROM MAIN_CUR INTO :DCL-TICKNO
002266 END-EXEC
002267 EVALUATE SQLCODE
002268 WHEN 0
002269 MOVE "TICKET SELECTED" TO MSGO
002270 PERFORM RECORD-PARA THRU RECORD-EXIT
002272 WHEN 100
002273 MOVE 'THERE IS NO RECENT TICKET' TO MSGO
002279 WHEN OTHER
002280 MOVE SQLCODE TO EC-SQLCODE
002282 MOVE 'NOT FETCHED PROPERLY' TO MSGO(1:20)
002283 MOVE EC-SQLCODE TO MSGO(21:9)
002284 END-EVALUATE


I have hard code the following code, what is happeneing here is fetch query is giving the sqlcode 0 it puts the record then after last fetch it gives
SQLCODE -50. I am not able to work out what is this sqlcode all about
Back to top
View user's profile Send private message
avinash pandey

New User


Joined: 10 Apr 2008
Posts: 17
Location: Bangalore

PostPosted: Sat May 30, 2009 10:53 am    Post subject: Reply to: DB2 SQLCODE -50
Reply with quote

Query is working fine since it is giving the desired output but at last fetch it giving -50
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Sat May 30, 2009 12:13 pm    Post subject:
Reply with quote

need to see EC-SQLCODE
and MSGO
Back to top
View user's profile Send private message
avinash pandey

New User


Joined: 10 Apr 2008
Posts: 17
Location: Bangalore

PostPosted: Sat May 30, 2009 12:17 pm    Post subject: Reply to: DB2 SQLCODE -50
Reply with quote

NOT FETCHED PROPERLY-00000050
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sat May 30, 2009 3:11 pm    Post subject:
Reply with quote

Hello,

Please post the definition and content of the entire sqlca. Also post the definitions of the other variables being used (i.e. ec-sqlcode, msgo).

At this point my guess is that after the process closes the cusor another fetch is issued that results in a -501 - which has been truncated to -50 somehow.

Looking at the code, do you see any for the process to attempt another fetch after the cursor has been closed?
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2158
Location: @my desk

PostPosted: Sat May 30, 2009 7:29 pm    Post subject:
Reply with quote

Code:
002282 MOVE 'NOT FETCHED PROPERLY' TO MSGO(1:20)
002283 MOVE EC-SQLCODE TO MSGO(21:9)

Code:
----+----+----+----+----+----
NOT FETCHED PROPERLY-00000050

Should n't the EC-SQLCODE be moved to MSGO(21:10) as SQLCODE is PIC S9(9) BINARY? Anyways post the field-definitions as requested above.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Sat May 30, 2009 10:33 pm    Post subject:
Reply with quote

another reason I am against reference modification
when simple data definitions would work...FR (foolish rookies!)

good catch Arun.
Back to top
View user's profile Send private message
avinash pandey

New User


Joined: 10 Apr 2008
Posts: 17
Location: Bangalore

PostPosted: Mon Jun 01, 2009 8:31 am    Post subject: Reply to: DB2 SQLCODE -50
Reply with quote

Thanks all for the replies
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Mon Jun 01, 2009 8:39 am    Post subject: Reply to: DB2 SQLCODE -50
Reply with quote

You're welcome - what did you find?

d
Back to top
View user's profile Send private message
avinash pandey

New User


Joined: 10 Apr 2008
Posts: 17
Location: Bangalore

PostPosted: Mon Jun 01, 2009 11:21 am    Post subject: Reply to: DB2 SQLCODE -50
Reply with quote

The problem was related to the declaration of variable i was passing 9 bytes instead of 10 bytes. I just increased one byte length


Thanks
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Mon Jun 01, 2009 11:28 am    Post subject:
Reply with quote

Hello,

Once the length of 10 was used, what was the actual problem sqlcode? I believe getting to the actual sqlcode was only the first part of the issue/resolution.
Back to top
View user's profile Send private message
avinash pandey

New User


Joined: 10 Apr 2008
Posts: 17
Location: Bangalore

PostPosted: Mon Jun 01, 2009 12:12 pm    Post subject:
Reply with quote

It was giving SQLCODE -501
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2158
Location: @my desk

PostPosted: Mon Jun 01, 2009 12:34 pm    Post subject:
Reply with quote

dick scherrer wrote:
At this point my guess is that after the process closes the cusor another fetch is issued that results in a -501 - which has been truncated to -50 somehow.

Looking at the code, do you see any for the process to attempt another fetch after the cursor has been closed?
avinash pandey,

Were you able to resolve it?
Back to top
View user's profile Send private message
avinash pandey

New User


Joined: 10 Apr 2008
Posts: 17
Location: Bangalore

PostPosted: Mon Jun 01, 2009 12:36 pm    Post subject:
Reply with quote

YES
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Mon Jun 01, 2009 9:50 pm    Post subject: Reply to: DB2 SQLCODE -50
Reply with quote

Good to hear it is working - thanks for letting us know icon_smile.gif

d
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 SQLCODE-000000080N priya91 DB2 1 Mon Feb 01, 2016 4:35 pm
No new posts Need to understand SQLCODE = 12 rohanthengal DB2 3 Thu Nov 05, 2015 11:22 am
No new posts SQLCODE -922 in Batch-Cics program tr... kishpra CICS 2 Thu Sep 10, 2015 12:36 pm
No new posts SQLCODE -450 for stored procedure spoorni DB2 3 Fri Jan 16, 2015 2:45 am
No new posts -81 SQLCODE returned when Remote Stor... kameswaramanoj.Akella DB2 1 Wed Dec 03, 2014 5:36 am


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