View previous topic :: View next topic
|
Author |
Message |
sushanth bobby
Senior Member
Joined: 29 Jul 2008 Posts: 1020 Location: India
|
|
|
|
Hello,
I want know, what this SQLCODE 00000080N stands for.
Sushanth |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
-805 |
|
Back to top |
|
|
sushanth bobby
Senior Member
Joined: 29 Jul 2008 Posts: 1020 Location: India
|
|
|
|
Dick,
How ? 00000080N = -805. Is there any conversion process to know the actual number(-805).
Sushanth |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
80N is the zoned-decimal representation of -805.
Do you know how to "read" zoned-decimal numbers in a file? |
|
Back to top |
|
|
sushanth bobby
Senior Member
Joined: 29 Jul 2008 Posts: 1020 Location: India
|
|
|
|
NOPE. Can you tell me, dick ? |
|
Back to top |
|
|
sushanth bobby
Senior Member
Joined: 29 Jul 2008 Posts: 1020 Location: India
|
|
|
|
Dick,
I just did a search in google for this error , there was already a post Here. But, he has resolved it using the SQLSTATE.
Can you tell me how to "READ the ZONED decimal numbers".
Sushanth |
|
Back to top |
|
|
sushanth bobby
Senior Member
Joined: 29 Jul 2008 Posts: 1020 Location: India
|
|
|
|
Hi,
I just google'd more & got this table.
Code: |
Digit EBCDIC Display
+0 {
+1 A
+2 B
+3 C
+4 D
+5 E
+6 F
+7 G
+8 H
+9 I
-0 }
-1 J
-2 K
-3 L
-4 M
-5 N
-6 O
-7 P
-8 Q
-9 R |
So, according the to the table & my error.
00000080N = 80N
80N = 80(-5)
80N = -805
Is this correct dick or is there any other method ?
Sushanth |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
The sign of a zoned-decimal number is in the high-order nibble of the low-order byte.
A cobol field of pic s9(5) with a value of +12345 is stored as 1234E (which is x'F1F2F3F4C5'). The "C" is the positive sign. A "D" is the negative sign. An "F" is no sign, but is treated as positive.
Positive values are from C0 thru C9, negative values are from D0 thru D9.
Quote: |
Is this correct dick or is there any other method ? |
That will work |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Here is your table with the hex added.
Code: |
Digit EBCDIC/Hex
Display
+0 { C0
+1 A C1
+2 B C2
+3 C C3
+4 D C4
+5 E C5
+6 F C6
+7 G C7
+8 H C8
+9 I C9
-0 } D0
-1 J D1
-2 K D2
-3 L D3
-4 M D4
-5 N D5
-6 O D6
-7 P D7
-8 Q D8
-9 R D9 |
|
|
Back to top |
|
|
sushanth bobby
Senior Member
Joined: 29 Jul 2008 Posts: 1020 Location: India
|
|
|
|
Thank You Dick,
Till now, i was thinkin SQLCODEs will be coming in numeric format like -805. Today only i got know, SQLCODEs might also come in this way.
Thank You Again for the Valuable information DICK.
Sushanth |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
You're welcome
d |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
sqlcode is a binary number, wether it is displayed in an intelligible form
depends only on the laziness of the programmer...
for -805 ==>
8 bytes for the CVD work area
15 bytes for the display area
15 bytes for the edit mask
1 instruction to convert from binary to packed
4 instructions for the edit
for 80n ==>
8 bytes for the CVD work area
15 bytes for the display area
1 instruction to convert from binary to packed
1 instructions to unpack to the display area |
|
Back to top |
|
|
sushanth bobby
Senior Member
Joined: 29 Jul 2008 Posts: 1020 Location: India
|
|
|
|
WOW, so there is so more in SQLCODE than, what meets the eye.
I got thank the DB2 designers for making, life of the programmer's easier, and i got to blame them for making them lazy...
Only, one thing i did'nt get ENRICO, what is CVD ?
Sushanth |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
from the POP ( principles of operations )
short format..
CVD[G] Register,Storage_location
Quote: |
The first operand is changed from binary to
decimal, and the result is stored at the second
operand location.
- For CONVERT TO DECIMAL (CVD), the
first operand is treated as a 32-bit signed binary
integer, and the result occupies eight bytes in
storage.
- For CONVERT TO DECIMAL (CVDG),
the first operand is treated as a 64-bit signed
binary integer, and the result occupies sixteen
bytes in storage.
The result is in the format for packed decimal data,
as described in Chapter 8, “Decimal Instructions.”
The rightmost four bits of the result
represent the sign. A positive sign is encoded as
1100; a negative sign is encoded as 1101.
|
|
|
Back to top |
|
|
sushanth bobby
Senior Member
Joined: 29 Jul 2008 Posts: 1020 Location: India
|
|
|
|
Thank U Enrico, for that pretty information. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
here is the full logic
Code: |
1 ...
2 ... call some subroutine to perform something
3 CALL Some_subroutine
4 LTR R15,R15
5 BZ Continue
6... extract the reason code
7... for brevity I assume that the feedback area is defined
8... and already addressable
9 L R15,Reason_Code
10 CVD R15,Double_Word
1... now the road diverge
2... lazy bum
3 UNPK Display_area,Double_Word
4... done
5... decent approach
6 MVC Display_area,=x'40202020202020202020202020202020212121'
7 LA R1,Display_area+1
8 EDMK Display_area,Double_word
9 BNM Not_negative
20 BCTR R1,0
1 MVI 0(R1),C'-'
2Not_negative DS 0H
3... the reason code is ready to be printed
4... continue with error processing
5... exit error processing
6Continue DS 0H
7...
8... work areas
9Double_Word DS D
30...
1Display_Area DS CL16
2...
|
here is the explanation ( code tag for the alignment )
Code: |
( 4) Load and test register, will return the condition code for the sign
( 5) Branch if zero
( 9) load the reason code in a register
for short term utilization 15 is OK
(10) Convert the binary content of reg 15 to a packed decimal
lets skip (11) (12) (13)
(16) move to the display area the edit mask
40 is the fill char ( for non significant )
20 is the edit indicator, space or non zero digit
21 digit even if is zero
the first non zero digit or the 21 will set the significance indicator
(17) load register 1 for neatness ( should not be needed anyway )
(18) EDIT and MARK,
will edit the number according to the mask and load in
register 1 the address of the first non zero digit
(19) edit will set the condition code
branch if not minus ( >= 0 )
(20) decrement register 1 by one
(21) move the minus
(29) the area for the packed result
(30) the display area
|
|
|
Back to top |
|
|
|