Reading Packed Decimal Data from Db2 table

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
Inquisitive
Charter Member
Charter Member
Posts: 88
Joined: Tue Jan 13, 2004 3:07 pm

Reading Packed Decimal Data from Db2 table

Post by Inquisitive »

Hi All,

I have posted this before, I am posting with some more information and a little different scenario, which could help me to get solutions faster.

I am trying to read DB2 table (Db2 on mainframe) which has Packed decimal data (Comp-3) stored in CHAR (Char2) field. I am using Db2 API stage to read data.

When I import table definitions, the field is defined as CHAR and 'view data' shows some un-readable data in the field. (I think these are Hex values)

I tried using function DataTypePicComp3 in transformer but it did not give proper results. It did uncompress but when I compared data against table it was not correct.

I am able to see the data in hex format in Mainframe.

Some sample data examples are

05156F
99125F

(F suggesting that it is not a signed decimal, This is readable when I log-in to mainframe and then turn Hex on)

Any solutions to this problem would be very helpful.

Thanks
Precious
Charter Member
Charter Member
Posts: 53
Joined: Mon Aug 23, 2004 9:51 am
Location: South Africa
Contact:

Post by Precious »

FYI

I was on a project where we were sourcing from DB2 on mainframe.
But in our case, we got data dumps from the mainframe in the form of flat files. These we read using the complex flat file stage. This stage has the relevant datatypes to allow you to read packed decimals. I know this is not a solution, but it could be an alternative. :wink:

Regards,
Precious

Mosher's Law of Software Engineering: Don't worry if it doesn't work right. If everything did, you'd be out of a job.
Inquisitive
Charter Member
Charter Member
Posts: 88
Joined: Tue Jan 13, 2004 3:07 pm

Post by Inquisitive »

Thanks for your comments Precious.

I have option of using CFF stage as well. I can take a dump of tables into a flat file and then read data through CFF stage.
But like I said source field is defined as Char(2) how do I set up CFF stage to read this comp-3 field? I tried setting up this field as decimal and then in selcting 'comp-3' in 'usage' tab of 'edit row' window for that particular column. It did not solve the problem either.

Also I tried usgin routine 'DataTypePicComp' which produced some negetive values, I am not sure if I am missing something here.

When I log-in to mainframe and turn 'Hex On' I see following values in the source table ..

Col1 Col2

005F 01353F
006F 02447F

Any pointer how we can read that? either using CFF or using SDK routines?

Thanks
Inquisitive
Charter Member
Charter Member
Posts: 88
Joined: Tue Jan 13, 2004 3:07 pm

Post by Inquisitive »

Here is the resolution to this problem,

I used SDK routine DataTypePicComp3 to convert comp3 into integer. I got it working only after reading the packed decimal field as BINARY from the source though it is defined as CHAR in the table. I just went ahead and changed datatype from CHAR to BINARY in DB2 API stage..............

..........Then they lived happily ever after :D
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

And you were so joyful that you marked the thread as Resolved!
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply