Converting Data
You can convert data from one data type to another.
To convert data from one data type to another, use one the following methods:
- •Pass data between ports (port-to-port data conversion).
- •Use transformation functions to convert data.
- •Use transformation arithmetic operators to convert data.
Port-to-Port Data Conversion
The Data Integration Service converts data based on the data type of the port. Each time data passes through a port, the Data Integration Service identifies the data type assigned to the port and converts the data based on the supported data type if required.
Pass Data Between Ports of the Same Data Type
You can create a mapping to pass data between ports of the same data type. When you pass data between ports of the same data type, the Data Integration Service passes data without changing the data or data type.
When you pass data between ports of the same numeric data type and the data is transferred between transformations, the Data Integration Service does not always convert the data to the precision and scale of the port that the data is passed to.
You can transfer Decimal data between ports of different precision, scale, and precision modes in the following ways:
- Pass Decimal data in low-precision mode
- If you pass data to a Decimal port in low-precision mode, the Data Integration Service converts all Decimal ports to Double with a precision of 15 and a scale of 0. For example, you pass a value from Decimal (14, 3) to Decimal (9, 5) in low-precision mode. The Data Integration Service stores the value internally and does not truncate the data in low-precision mode.
- Pass Decimal data with reduced scale in high-precision mode
- If you pass data to a Decimal port in high-precision mode and with reduced scale between the Decimal ports, scale truncation occurs. For example, you pass a value from Decimal (18, 5) to Decimal (18, 2). When you pass 18.01234, the Data Integration Service truncates the scale of the data and the output data is 18.01.
- Pass Decimal data with reduced precision in high-precision mode
- You can pass data to a Decimal port in high-precision mode with reduced precision. For example, you pass a value from Decimal (19, 5) to a Decimal (17, 2) in high-precision mode. When the output field contains a value that exceeds 17 digits, the Data Integration Service rejects the row.
Pass Data Between Ports of Different Data Types
When you pass data between ports of different data types, the Data Integration Service uses the conversion functions in the transformation language to convert the data from one data type to another.
For example, you connect a String port to an Integer port. When the Data Integration Service runs the mapping, it uses the TO_INTEGER function to convert the input data from a string to an integer data type.
When the Data Integration Service performs port-to-port conversions, the data that you pass must be valid for the conversion data type. Any value that the Data Integration Service cannot convert results in a transformation row error. For example, you connect a String port that contains the value "9,000,000,000,000,000,000.777" to a Bigint port. The Data Integration Service cannot convert the String to a Bigint value and returns an error.
The Data Integration Service performs port-to-port conversions between transformations and between the last transformation in a pipeline and a target.
The following table describes the port-to-port conversions that the Data Integration Service performs:
Data Type | Bigint | Integer | Decimal | Double | String, Text | Date/Time | Binary | Timestamp with Time Zone |
---|
Bigint | No | Yes | Yes | Yes | Yes | No | No | No |
Integer | Yes | No | Yes | Yes | Yes | No | No | No |
Decimal | Yes | Yes | No | Yes | Yes | No | No | No |
Double | Yes | Yes | Yes | No | Yes | No | No | No |
String, Text | Yes | Yes | Yes | Yes | Yes | Yes | No | Yes |
Date/Time | No | No | No | No | Yes | Yes | No | No |
Binary | No | No | No | No | No | No | Yes | No |
Timestamp with Time Zone | No | No | No | No | Yes | No | No | Yes |