Table of Contents

Search

  1. Preface
  2. The Transformation Language
  3. Constants
  4. Operators
  5. Variables
  6. Dates
  7. Functions
  8. Creating Custom Functions
  9. Custom Function API Reference

Transformation Language Reference

Transformation Language Reference

TO_CHAR (Numbers)

TO_CHAR (Numbers)

Converts numeric values to text strings. TO_CHAR also converts dates to strings.
TO_CHAR converts double values to text strings as follows:
  • Converts double values of up to 16 digits to strings and provides accuracy up to 15 digits. If you pass a number with more than 15 digits, TO_CHAR rounds the number based on the sixteenth digit and returns the string representation of the number in scientific notation. For example, 1234567890123456 double value converts to '1.23456789012346e+015' string value.
  • Returns decimal notation for numbers in the ranges (-1e16,-1e-16] and [1e-16, 1e16). TO_CHAR returns scientific notation for numbers outside these ranges. For example, 10842764968208837340 double value converts to '1.08427649682088e+019' string value.
TO_CHAR converts decimal values to text strings as follows:
  • In high precision mode, TO_CHAR converts decimal values of up to 28 digits to strings. If you pass a decimal value with more than 28 digits, TO_CHAR returns scientific notation for numbers greater than 28 digits.
  • In low precision mode, TO_CHAR treats decimal values as double values.

Syntax

TO_CHAR(
numeric_value
)
The following table describes the argument for this command:
Argument
Required/
Optional
Description
numeric_value
Required
Numeric data type. The numeric value you want to convert to a string. You can enter any valid transformation expression.

Return Value

String.
NULL if a value passed to the function is NULL.

Double Conversion Example

The following expression converts the double values in the SALES port to strings:
TO_CHAR( SALES )
SALES
RETURN VALUE
1010.99
'1010.99'
-15.62567
'-15.62567'
10842764968208837340
'1.08427649682088e+019'
  (rounded based on the 16th digit and returns the value in scientific notation)
236789034569723
'236789034569723'
0
'0'
33.15
'33.15'
NULL
NULL

Decimal Conversion Example

The following expression converts the decimal values in the SALES port to strings in high precision mode:
TO_CHAR( SALES )
SALES
RETURN VALUE
2378964536789761
'2378964536789761'
1234567890123456789012345679
'1234567890123456789012345679'
1.234578945469649345876123456
'1.234578945469649345876123456'
0.999999999999999999999999999
'0.999999999999999999999999999'
12345678901234567890123456799
(greater than 28)
'1.23456789012346e+028'

0 COMMENTS

We’d like to hear from you!