Purpose
TO_NCHAR(number) converts 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 | The format of the return value. This parameter is optional. If fmt is omitted, n is converted to an NVARCHAR2 value to be returned. For information about values for fmt, see “Values for fmt”. |
| nlsparam | The decimal character, group separator, local currency symbol, and international currency symbol. This parameter is optional. |
Values for fmt
| Value | Description |
|---|---|
| 9 | Returns a value with the 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 a number format model. Restriction: A number format model cannot start with a comma (,) and a comma (,) cannot appear to the right of a decimal character or period (.). |
| . (decimal point) | Returns a decimal number with the decimal point at the specified position. Restriction: You can specify only one decimal point in a number format model. |
Return type
The return type is NVARCHAR2.
Examples
The following example converts 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