Purpose
This function converts a value of the NUMBER, BINARY_FLOAT, or BINARY_DOUBLE data type 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 | An optional output format parameter. If you omit fmt, then n is converted to an NVARCHAR2 value and returned. For more information, see the fmt section. |
| nlsparam | An optional parameter that defines the decimal character, group separator, local currency symbol, and international currency symbol. |
fmt section
fmt Parameter Value |
Description |
|---|---|
| 9 | Returns a value with a specified number of digits. |
| 0 | Returns a value with specified leading and trailing 0 characters. |
| , (comma) | Returns a comma in the specified position. You can specify multiple commas in a number format model. Limitation : A number format model cannot start with a comma, and a comma cannot appear to the right of a decimal character or a period. |
| . (period) | Returns a decimal value with the decimal point in the specified position. Limitation : You can specify only one decimal point in a number format model. |
Return type
NVARCHAR2
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
