string to decimal

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
Abhijeet
Participant
Posts: 20
Joined: Wed Jul 27, 2005 1:00 am

string to decimal

Post by Abhijeet »

Hi ,

what would be the expected output if i try to read a string say "1024" using datatype decimal[4,2] in a sequential file ?

also what will be the output if the string is 10.

Please reply , I dont have an environment to check these things. :)

Thanks
ajmore
Participant
Posts: 22
Joined: Fri Aug 25, 2006 5:25 am

Re: string to decimal

Post by ajmore »

Abhijeet wrote:Hi ,

what would be the expected output if i try to read a string say "1024" using datatype decimal[4,2] in a sequential file ?

also what will be the output if the string is 10.

Please reply , I dont have an environment to check these things. :)

Thanks
Hi Abhi...
The Expected output is 1024.00 using Datatype decimal[4,2] and for 10 it is 10.00 ....
can anyone specify why it may be so.... :shock:
jayantthakore
Participant
Posts: 42
Joined: Tue Jan 18, 2005 5:48 am

Post by jayantthakore »

HI Abhi,

Decimal[4,2] will give output 1024.00.
But String 10 will only give '1024' if its a VarChar or '1024 ' if its a Char.
regards,
Jayant S Thakore
Mike
Premium Member
Premium Member
Posts: 1021
Joined: Sun Mar 03, 2002 6:01 pm
Location: Tampa, FL

Post by Mike »

Decimal[4,2] is a 3-byte packed decimal. I would expect that you should get an error if you try to read strings like "1024" and "10" as if they were packed decimal. I think you will need to read them in as strings and then convert them to decimal.

Mike
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Decimal(4,2) ment total length is 4 and out of it, precision is 2. And hence the mantissa is also 2 here. If it is fixed width 4 consicutive digit can be read as 4,2.
In case of delimited input, 10 will be considired as 10.00.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

It is always safest to treat text files as if they contain text as the only data type. Within the DataStage job you can then apply data type conversion functions using a Modify stage or a Transformer stage. The obvious exception is when you know that there are binary data in the "text" file.
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