Oracle TO_NCHAR(character) Function

Oracle TO_NCHAR(character) is a built-in function that converts NCHAR, NVARCHAR2, CLOB, or NCLOB data to the national character set.

Oracle TO_NCHAR(character) Syntax

Here is the syntax for the Oracle TO_NCHAR(character) function:

TO_NCHAR(nchar | clob | nclob)

Parameters

nchar | clob | nclob

Required.

Return Value

The Oracle TO_NCHAR(character) function returns a value of type VARCHAR2 that converts the given NCHAR, NVARCHAR2, CLOB, or NCLOB data to the national character set.

When you use this function to convert character LOBs to the national character set, if the LOB value being converted is larger than the target type, the database returns an error.

Oracle TO_NCHAR(character) Example

The following example converts several simple strings to character data:

SELECT
    TO_NCHAR('0111'),
    TO_NCHAR('ABCD'),
    TO_NCHAR('A1B2')
FROM dual;

输出:

TO_NCHAR('0111')    TO_NCHAR('ABCD')    TO_NCHAR('A1B2')
___________________ ___________________ ___________________
0111                ABCD                A1B2

Conclusion

Oracle TO_NCHAR(character) is a built-in function that converts NCHAR, NVARCHAR2, CLOB, or NCLOB data to the national character set.