|
View previous topic :: View next topic
|
| Author |
Message |
speermb
New User
Joined: 27 Aug 2008 Posts: 30 Location: USA
|
|
|
|
Does use of DB2 function in UNLOAD return indicators or something? When I do straight unload I get good data. When I add ABS or CASE data after that function column is pushed over 1 byte. Is there an option I need to use to ensure this doesnt happen?
| Code: |
UNLOAD
FIXEDVARCHAR YES
DIRECT NO
SELECT TAB1.PYR_ID
,TAB2.YR_DT
,TAB3.ACCT_CD
,TAB3.ACCT
,TAB3.TRAN_QTY
,TAB3.TRAN_AMT
,TAB3.TRAN_ID
|
My output looks good:
| Code: |
TRAN_QTY TRAN_AMT TRN-ID
9/PS 9/PS 6/PS
(104-112) (113-121) (122-127)
15-------------------- 16-------------------- 17---------------------
********************************* TOP OF DATA **********************-
& j qo<
000050000 000005930 052994
00000000D 00000715D 01286C
---------------------------------------------------------------------
r qo
000070000 000007590 052990
00000000D 00000549D 01286C
---------------------------------------------------------------------
' qm
000000000 000004757 052990
00002000D 00000977D 01284C
---------------------------------------------------------------------
e qj
000000000 000002870 052999
00010000D 00001450D 01281C
---------------------------------------------------------------------
& & q
000050000 000005000 052990
00000000D 00000000D 01280C
---------------------------------------------------------------------
qe
000000000 000000000 052982
00000000C 00000010C 01285C
|
When I do ABS the unload it looks like a get INDICATOR between the QTY & AMT columns.
| Code: |
UNLOAD
FIXEDVARCHAR YES
DIRECT NO
SELECT TAB1.PYR_ID
,TAB2.YR_DT
,TAB3.ACCT_CD
,TAB3.ACCT
,ABS(TAB3.TRAN_QTY)
,TAB3.TRAN_AMT
,TAB3.TRAN_ID |
My output looks like
| Code: |
TRAN_QTY TRAN_AMT TRN-ID
9/PS 9/PS 6/PS
(104-112) (113-121) (122-127)
15-------------------- 16-------------------- 17---------------------
********************************* TOP OF DATA **********************-
& j qo
000050000 000000593 005299
00000000C 000000715 D01286
-------------------------------------------------------------------------------
r qo
000070000 000000759 005299
00000000C 000000549 D01286
-------------------------------------------------------------------------------
' qm
000000000 000000475 705299
00002000C 000000977 D01284
-------------------------------------------------------------------------------
e qj
000000000 000000287 005299
00010000C 000001450 D01281
-------------------------------------------------------------------------------
& & q
000050000 000000500 005299
00000000C 000000000 D01280
-------------------------------------------------------------------------------
qe
000000000 000000000 005298
00000000C 000000010 C01285
|
When I do CASE the unload it looks like a get all ZEROS in the QTY field
| Code: |
UNLOAD
FIXEDVARCHAR YES
DIRECT NO
SELECT TAB1.PYR_ID
,TAB2.YR_DT
,TAB3.ACCT_CD
,TAB3.ACCT
,DEC(CASE
WHEN TAB3.TRAN_QTY < +0
THEN TAB3.TRAN_QTY * -1
WHEN TAB3.TRAN_QTY > +0
THEN TAB3.TRAN_QTY
END,17,4)
,TAB3.TRAN_AMT
,TAB3.TRAN_ID
|
| Code: |
TRAN_QTY TRAN_AMT TRN-ID
9/PS 9/PS 6/PS
(104-112) (113-121) (122-127)
15-------------------- 16-------------------- 17---------------------
GPA067C1-AC-TR-TXRP-QY GPA067C1-AC-TR-TXRP-AM GPA067C1-TXRP-DTL-TR-ID
9/PS 9/PS 6/PS
(104-112) (113-121) (122-127)
15-------------------- 16-------------------- 17---------------------
000080000 000000800 004057
00000000C 000000000 D05012
-------------------------------------------------------------------------------
000070000 000000700 004057
00005000C 000000500 D05012
-------------------------------------------------------------------------------
000080000 000000800 004444
00000000C 000000000 D05675
-------------------------------------------------------------------------------
000070000 000000700 004444
00005000C 000000500 D05675
-------------------------------------------------------------------------------
000070000 000000700 004057
00005000C 000000500 D05012
-------------------------------------------------------------------------------
000070000 000000700 004444
00005000C 000000500 D05675 |
|
|
| Back to top |
|
 |
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
| SQL Reference Guide : ABS wrote: |
| The result of the function has the same data type and length attribute as the argument. The result can be null. If the argument is null, the result is the null value. |
| Utility guide and reference:Figure 103. Layout of a nullable fixed-length field wrote: |
| The following figure shows the layout of a fixed-length field that can be null. This diagram shows that a null indicator byte is stored before the data field, which begins at the specified position or at the next byte position past the end of the previous data field. |
And if you would have looked at SYSPUNCH (possibly set to dummy in your JCL) you could have guessed this.
try: cast(coalesce(abs(TAB3.TRAN_QTY),0) as dec(17,4)) |
|
| Back to top |
|
 |
speermb
New User
Joined: 27 Aug 2008 Posts: 30 Location: USA
|
|
|
|
| Thanks very much. You are correct my syspunch was dummy. I did look in the manual, I missed the RESULT CAN BE NULL AND NULL IND will be returned. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|