Page 1 of 1

Convert String to BigInt

Posted: Wed Feb 15, 2012 5:19 pm
by gagan8877
I am trying to convert string field to Decimal in Transformer using:

StringToDecimal(string_field)

inside a Stage variable of datatype decimal(10, 0) and string_field is varchar(10).

but I get:

Transformer_7,1: Fatal Error: APT_Decimal::assignFromUInt64: the integer source (100013001) is out of range for a decimal with precision 8 and scale 0. [decimal/decimal.f.C:945]

Also tried with Decimal (15,0) as stage variable's data type - same error.

Is there a workaround in transformer? Will I have to use Modify stage?

Thanks
Gary

Posted: Wed Feb 15, 2012 5:30 pm
by qt_ky
100013001 has precision of 9 hence the error it won't fit into precision 8. Can you use a larger precision on your decimal data type?

Posted: Wed Feb 15, 2012 5:42 pm
by ray.wurlod
You can't fit a size 9 foot into a size 8 shoe. This is similar.

Posted: Wed Feb 15, 2012 5:50 pm
by gagan8877
Good analogy and thanks for the replies - I edited the original post to give you guys more info.

StringToDecimal(string_field)

basically the derivation is inside a Stage variable of datatype decimal(10, 0) and string_field is varchar(10).

Posted: Wed Feb 15, 2012 5:57 pm
by ray.wurlod
The message suggests that, somehow, DataStage is still seeing Decimal(8,0) as the data type. Time for some detective work.

Posted: Thu Feb 16, 2012 8:49 pm
by dongyingying
Hi ,after you changed it ,did you recompiled it . if you did ,i think ,there will be something wrong of you datatype and even you transformer .