Table of Contents

Search

  1. Preface
  2. The Transformation Language
  3. Constants
  4. Operators
  5. Variables
  6. Dates
  7. Functions

Transformation Language Reference

Transformation Language Reference

TO_INTEGER

TO_INTEGER

Converts a string or numeric value to an integer. TO_INTEGER syntax contains an optional argument that you can choose to round the number to the nearest integer or truncate the decimal portion. TO_INTEGER ignores leading blanks.

Syntax

TO_INTEGER(
value
[,
flag
] )
The following table describes the arguments for this command:
Argument
Required/
Optional
Description
value
Required
String or numeric datatype. Passes the value you want to convert to an integer. You can enter any valid transformation expression.
flag
Optional
Specifies whether to truncate or round the decimal portion. The flag must be an integer literal or the constants TRUE or FALSE.
TO_INTEGER truncates the decimal portion when the flag is TRUE or a number other than 0.
TO_INTEGER rounds the value to the nearest integer if the flag is FALSE or 0 or if you omit this argument.

Return Value

Integer.
NULL if the value passed to the function is NULL.
If the value passed to the function contains data that is not valid for an integer value, the Data Integration Service marks the row as an error row or fails the mapping.

Examples

The following expressions use values from the port IN_TAX. The
Data Integration Service
displays an error when the conversion causes a numeric overflow:
TO_INTEGER( IN_TAX, TRUE )
IN_TAX
RETURN VALUE
'15.6789'
15
'60.2'
60
'118.348'
118
'5,000,000,000'
Error. Integration Service skips this row.
NULL
NULL
'A12.3Grove'
Error. Integration Service skips this row.
'    123.87'
123
'-15.6789'
-15
'-15.23'
-15
TO_INTEGER( IN_TAX, FALSE)
IN_TAX
RETURN VALUE
'15.6789'
16
'60.2'
60
'118.348'
118
'5,000,000,000'
Error. Integration Service skips this row.
NULL
NULL
'A12.3Grove'
Error. Integration Service skips this row.
'    123.87'
124
'-15.6789'
-16
'-15.23'
-15

0 COMMENTS

We’d like to hear from you!