View previous topic :: View next topic
|
Author |
Message |
Anita Etury
New User
Joined: 21 Nov 2007 Posts: 3 Location: India
|
|
|
|
Hi,In my COBOL-DB2 program, I am trying to handle SQL ERRors .
But it is displaying SQLCODE in zoned decimal format.
For eg. for SQLCODE -803, it is displaying as 00000080L.
Here's the part of code :
************************************************************
EXEC SQL
INSERT INTO TESTR04.CUSTMXXX(CUSTM_NO,CUSTM_NAME,
CUSTM_ADDR,CUSTM_DOB)
VALUES (:CUSTM-NO,:CUSTM-NAME,:CUSTM-ADDR,:CUSTM-DOB)
END-EXEC.
DISPLAY 'SQLCODE: ' SQLCODE
EVALUATE SQLCODE
WHEN 0
continue
WHEN -803
DISPLAY 'CUSTOMER ALREADY EXISTS IN the TABLE'
PERFORM error-processing
When other
Perform eror-processing
END-EVALUATE
**********************************************************
Here SQLCODE is in zoned-decimal format, Hence, the control is not going to the point WHEn -803 DISPLAY 'CUSTOMER .....'
So i want that to be in signed integer (0000080N to be displayed as -803), so that SQL error handling can be done as desired in the program.
How can I do that ? |
|
Back to top |
|
|
Gnanas N
Active Member
Joined: 06 Sep 2007 Posts: 792 Location: Chennai, India
|
|
|
|
No, SQLCODE is with COMP data type.
Quote: |
Here SQLCODE is in zoned-decimal format, Hence, the control is not going to the point WHEn -803 DISPLAY 'CUSTOMER .....' |
Not true; "WHEN -803" will work perfect when the last executed SQL has -803 as SQLCODE of SQLCA. The format you're concerned here doesn't matter. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Define a field as -(3)9, or -999 or some edited format that you like better, move your signed-zoned (also works with signed-packed) to that new field, and display the new field. |
|
Back to top |
|
|
Anita Etury
New User
Joined: 21 Nov 2007 Posts: 3 Location: India
|
|
|
|
Hi team,
Thanks a lot for the quick response !
@ Bill.. Thanks for the solution It works fine !!! |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
No
0000080N is equivalent to -805 ( Bind issue)
An excellent post by Dick on Zoned Decimal Conversion
could help
Check here for the post |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Anita Etury,
Glad to hear it is working.
Please be careful when posting, paste from your emulator screen wherever possible. You introduced confusion, picked up by Pandora-Box, over the 803, as you referred to it appearing also as 80N. Have a look at the link Pandora-Box provided, and you can also get the answer, when needed, without using the edited field. |
|
Back to top |
|
|
Anita Etury
New User
Joined: 21 Nov 2007 Posts: 3 Location: India
|
|
|
|
Sure ! Thanks |
|
Back to top |
|
|
|