Page 1 of 1

problem with string to decimal conversion

Posted: Mon Sep 24, 2007 12:47 pm
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

Re: problem with string to decimal conversion

Posted: Mon Sep 24, 2007 1:08 pm
by kris
Conversion error calling conversion routine decimal_from_string data may have been lost.


Try "trim" and then convert.
StringToDecimal(Trim(XXX))

Posted: Mon Sep 24, 2007 2:22 pm
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].

Re: problem with string to decimal conversion

Posted: Mon Sep 24, 2007 11:36 pm
by changming
in transform set to input.field/1, convert null to '0' , set the output datatype to Decimal(5,3).
It will work

Posted: Tue Sep 25, 2007 12:44 am
by ray.wurlod
Yeah? What about 130 and 1460?