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

DB2 SQLCODE -50


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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

Moderator Emeritus


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

PostPosted: Sat May 30, 2009 10:45 am
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
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
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
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
Reply with quote

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

Moderator Emeritus


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

PostPosted: Sat May 30, 2009 3:11 pm
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: 2481
Location: @my desk

PostPosted: Sat May 30, 2009 7:29 pm
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
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
Reply with quote

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

Moderator Emeritus


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

PostPosted: Mon Jun 01, 2009 8:39 am
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
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

Moderator Emeritus


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

PostPosted: Mon Jun 01, 2009 11:28 am
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
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: 2481
Location: @my desk

PostPosted: Mon Jun 01, 2009 12:34 pm
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
Reply with quote

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

Moderator Emeritus


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

PostPosted: Mon Jun 01, 2009 9:50 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts SQLCODE = -122 while using the scalar... DB2 4
No new posts SQLCODE = -16002 when using XMLEXISTS DB2 1
No new posts Is SQLCODE -811 possible while fetchi... DB2 1
No new posts SQLCODE=-204 SQLSTATE=42704 DB2 4
No new posts Getting sqlcode 805 while executing R... DB2 10
Search our Forums:

Back to Top