Purpose
You can call this function to convert a NUMBER, BINARY_FLOAT, or BINARY_DOUBLE value to a string in the national character set.
Syntax
TO_NCHAR(n [, fmt [, 'nlsparam' ] ])
Parameters
| Parameter | Description |
|---|---|
| n | A value of the NUMBER, BINARY_FLOAT, or BINARY_DOUBLE data type. |
| fmt | (Optional) The parameter that specifies the output format. If fmt is omitted, n is converted to an NVARCHAR2 value to be returned. For more information, see fmt argument values. |
| nlsparam | (Optional) Defines decimal characters, group separators, local currency symbols, and international currency symbols. |
fmt argument values
| fmt argument value | Description |
|---|---|
| 9 | Returns a value with a specified number of digits. |
| 0 | Returns the specified leading and trailing 0. |
| , (comma) | Returns a comma (,) at the specified position. You can specify multiple commas in the number format model. Limits: A format model value cannot start with a comma. In addition, commas cannot appear to the right of decimal characters or periods. |
| . (decimal point) | Returns a decimal number where the decimal point is in the specified position. Limit: You can specify only one decimal point in a number format model. |
Return types
This function returns the NVARCHAR2 data type.
Examples
Convert 123456789.123 to a value in the 999,999,999 format.
obclient> SELECT TO_NCHAR(123456789.123,'999,999,999') FROM DUAL;
+---------------------------------------+
TO_NCHAR(123456789.123,'999,999,999')
+---------------------------------------+
123,456,789
+---------------------------------------+
1 row in set