Transformation Language Reference > Functions > TO_DECIMAL
  

TO_DECIMAL

Converts a string or numeric value to a decimal value. TO_DECIMAL ignores leading blanks.

Syntax

TO_DECIMAL( value [, scale] )
The following table describes the arguments for this command:
Argument
Required/
Optional
Description
value
Required
Must be a string or numeric datatype. Passes the values you want to convert to decimal values. You can enter any valid transformation expression.
scale
Optional
Must be an integer literal between 0 and 28, inclusive. Specifies the number of digits allowed after the decimal point. If you omit this argument, the function returns a value with the same scale as the input value.

Return Value

Decimal of precision and scale between 0 and 28, inclusive.
NULL if a value passed to the function is NULL.
If the string contains a non-numeric character, converts the numeric portion of the string up to the first non-numeric character.
If the first numeric character is non-numeric, returns 0.

Example

This expression uses values from the port IN_TAX. IN_TAX is a String data type with precision of 44 digits. RETURN VALUE is a Decimal data type with a precision of 28 and scale of 3:
TO_DECIMAL( IN_TAX, 3 )
IN_TAX
RETURN VALUE
'15.6789'
15.679
'60.2'
60.200
'118.348'
118.348
NULL
NULL
'A12.3Grove'
0
'711A1'
711
'1234567890.123'
1234567890.123
'123456789012345678901234567890.123'
Error. Integration Service skips this row.
'1234567890123456789012345678901234567890.123
Error. Integration Service skips this row.