View previous topic :: View next topic
|
Author |
Message |
avinash pandey
New User
Joined: 10 Apr 2008 Posts: 17 Location: Bangalore
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 |
|
|
avinash pandey
New User
Joined: 10 Apr 2008 Posts: 17 Location: Bangalore
|
|
|
|
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 |
|
|
avinash pandey
New User
Joined: 10 Apr 2008 Posts: 17 Location: Bangalore
|
|
|
|
Query is working fine since it is giving the desired output but at last fetch it giving -50 |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
need to see EC-SQLCODE
and MSGO |
|
Back to top |
|
|
avinash pandey
New User
Joined: 10 Apr 2008 Posts: 17 Location: Bangalore
|
|
|
|
NOT FETCHED PROPERLY-00000050 |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
another reason I am against reference modification
when simple data definitions would work...FR (foolish rookies!)
good catch Arun. |
|
Back to top |
|
|
avinash pandey
New User
Joined: 10 Apr 2008 Posts: 17 Location: Bangalore
|
|
|
|
Thanks all for the replies |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
You're welcome - what did you find?
d |
|
Back to top |
|
|
avinash pandey
New User
Joined: 10 Apr 2008 Posts: 17 Location: Bangalore
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 |
|
|
avinash pandey
New User
Joined: 10 Apr 2008 Posts: 17 Location: Bangalore
|
|
|
|
It was giving SQLCODE -501 |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
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 |
|
|
avinash pandey
New User
Joined: 10 Apr 2008 Posts: 17 Location: Bangalore
|
|
|
|
YES |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Good to hear it is working - thanks for letting us know
d |
|
Back to top |
|
|
|