View previous topic :: View next topic
|
Author |
Message |
rajendraa
New User
Joined: 22 Dec 2006 Posts: 7 Location: Bangalore
|
|
|
|
Hi,
I have a requirement to unload data from DB2 table to flat file and use the file in one of our existing production program.
Following are the field descriptions of the amount field in DB2 table, unload file and production program.
DB2 Field DECIMAL(15,2)
Field in DB2 Unload File PIC S9(13)V9(2) USAGE COMP-3 (1-8 bytes)
Field in Program PIC S9(16)V99 COMP-3. (1-10 bytes)
When I downloaded the data from DB2 table for one of amount column (which is of DECIMAL(15,2)), it was stored in the flat file as packed decimal (PIC S9(13)V9(2) USAGE COMP-3).
Since my production program will accept only PIC S9(16)V99 COMP-3, I am trying to edit the field using sort.
I tried with the following option in my outrec field
OUTREC FIELDS=(1:X'0000',3:1,8)
The results seem to be correct. Can some one let me know if this is correct approach or not.
Thanks |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
rajendraa,
Well that is one of the right approach. However you can use Z for binary zeroes like this
Code: |
OUTREC FIELDS=(2Z,1,8)
|
On the other hand I wonder why you need an additional sort pass to pad the zeroes when the same can be done in the unload step itself like this?
Code: |
SELECT CAST(your_dec(15,2)_column AS DECIMAL(18,2))
FROM TABLE;
|
|
|
Back to top |
|
|
rajendraa
New User
Joined: 22 Dec 2006 Posts: 7 Location: Bangalore
|
|
|
|
Thank you Skolusu |
|
Back to top |
|
|
|