Page 1 of 1

Double to Decimal Data Type Issue

Posted: Sun Apr 22, 2012 5:49 pm
by ds2000
My source is double data type and using dFloatToDecimal function to send to target column decimal(16,12), i get warning message for the source data value of 13456.123456789012 and its displayed as zeroes but when i change target column to decimal(16,11) no warning but value is rounded. Even if i increase the size to decimal(20,20) i see zeroes there only. i want to understand How is data stored in decimal in datastage and how can i fix it, if anyone can comment please.

Thanks in advance.

Re: Double to Decimal Data Type Issue

Posted: Sun Apr 22, 2012 6:33 pm
by SURA
First point

Your sample data is 13456.123456789012
Your target column decimal(16,12) /decimal(16,11)

It is not correct. Is it the real data or you gives some data for example?

Posted: Sun Apr 22, 2012 6:36 pm
by qt_ky
Precision is number of digits and scale is number of digits to the right of the decimal. Your sample number, 13456.123456789012, has a precision of 17 and a scale of 12, which is decimal(17,12).

Posted: Mon Apr 23, 2012 11:59 am
by ds2000
Thanks qt_ky and SURA to to explain the storage of numeric.

My actual data value was 14656.495444480958, that becomes Numeric(17, 12) and it works fine. I have increased the total precision to 20 to fit max value that i found in the table.

Final Conclusion

Posted: Tue Apr 24, 2012 10:10 am
by ds2000
To get rid of this Warning:
APT_CombinedOperatorController,2: Conversion error calling conversion routine decimal_from_dfloat data may have been lost

and Following this rule:
Precision is number of digits and scale is number of digits to the right of the decimal.

scale/decimal value (right part of decimal) first uses total no of precision/digits size as defined in the column defintion and remaining precision/digits size is provided for left part of decimal.

Example:

12345.123456789012 will fit into Numeric(17, 12) because total Precision/Digits size is 17 and after decimal size is 12 and before decimal size is 5.

this value willnot fit into Numeric(16, 12) as per rule and will issue above mentioned warnig.