problem with string to decimal conversion

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
pattemk
Participant
Posts: 84
Joined: Wed May 16, 2007 4:04 pm

problem with string to decimal conversion

Post by pattemk »

hi,

i have two sequence of jobs, one writing data from seq file to dataset and other is to load the data from the dataset(o/p from the first job) into an oracle table.

input:-seq file, 5 columns. for "qty" column, datatype of varchar, no fixed length and nullable. it has values like 30,4,120,1340, ...

i am trying to do a transform from varchar, no lenght and nullable TO decimal, length 5 scale 3 and nullable.

i tried stringToDecimal, but i am getting the o/p as below

inp
qty
4
30
130
60
1450

o/p
04.000
30.000
00.000
60.000
00.000

and i am getting the following warning.
Conversion error calling conversion routine decimal_from_string data may have been lost.

all i need is to get the same numbers as in the input but i need them in number format.

can anyone help me out.

thanks
kris
Participant
Posts: 160
Joined: Tue Dec 09, 2003 2:45 pm
Location: virginia, usa

Re: problem with string to decimal conversion

Post by kris »

Conversion error calling conversion routine decimal_from_string data may have been lost.


Try "trim" and then convert.
StringToDecimal(Trim(XXX))
~Kris
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

DataStage's data browser (View Data) always displays decimal numbers with leading and trailing zeroes, so that you can check that the precision and scale are being handled correctly.

Neither 130 nor 1460 can be represented as decimal[5,3] because that data type allows for not more than two digits to the left of the decimal place. This is what has caused the messages to be generated. To represent 1460 as a decimal number with three decimal places you need at least decimal[7,3].
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
changming
Participant
Posts: 68
Joined: Wed Oct 13, 2004 3:35 am

Re: problem with string to decimal conversion

Post by changming »

in transform set to input.field/1, convert null to '0' , set the output datatype to Decimal(5,3).
It will work
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Yeah? What about 130 and 1460?
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