Oracle NLS_CHARSET_NAME() Function

Oracle NLS_CHARSET_NAME() is a built-in function that returns the character set name corresponding to the given character set ID.

The NLS_CHARSET_NAME() function is the opposite of the NLS_CHARSET_ID() function.

Oracle NLS_CHARSET_NAME() Syntax

Here is the syntax for the Oracle NLS_CHARSET_NAME() function:

NLS_CHARSET_NAME(charset_id)

Parameters

charset_id

Required. The character set ID. It should be a number.

Return Value

The Oracle NLS_CHARSET_NAME() function returns the character set name corresponding to the given character set ID. This function should return a VARCHAR2 value.

If the given character set ID is not recognized as a valid character set ID, the function returns NULL.

If any parameter is NULL, NLS_CHARSET_NAME() returns NULL.

Oracle NLS_CHARSET_NAME() Examples

Here are some examples that demonstrate the usage of the Oracle NLS_CHARSET_NAME() function.

Basic Usage

SELECT
    NLS_CHARSET_NAME(100)
FROM dual;

Output:

NLS_CHARSET_NAME(2)
______________________
WE8DEC

Here’s another example:

SELECT
    NLS_CHARSET_NAME(862)
FROM dual;

Output:

NLS_CHARSET_NAME(862)
________________________
ZHT16DBT

NULL Parameters

If any parameter is NULL, NLS_CHARSET_NAME() returns NULL.

SET NULL 'NULL';
SELECT
    NLS_CHARSET_NAME(NULL)
FROM dual;

Output:

NLS_CHARSET_NAME(NULL)
_________________________
NULL

In this example, we use the SET NULL 'NULL'; statement to display the NULL value as the string 'NULL'.

Conclusion

The Oracle NLS_CHARSET_NAME() is a built-in function that returns the character set name corresponding to the given character set ID.