Oracle NLS_CHARSET_ID() Function
Oracle NLS_CHARSET_ID()
is a built-in function that returns the ID corresponding to the given character set name.
The NLS_CHARSET_ID()
function is the opposite of the NLS_CHARSET_NAME()
function.
Oracle NLS_CHARSET_ID()
Syntax
Here is the syntax for the Oracle NLS_CHARSET_ID()
function:
NLS_CHARSET_ID(charset_name)
Parameters
charset_name
-
Required. The character set name. It should be a
VARCHAR2
value.
Return Value
The Oracle NLS_CHARSET_ID()
function returns the ID corresponding to the given character set name.
If you provide an invalid character set name, the function will return NULL
.
If any of the parameters are NULL
, NLS_CHARSET_ID()
will return NULL
.
Oracle NLS_CHARSET_ID()
Examples
Here are some examples that demonstrate the usage of the Oracle NLS_CHARSET_ID()
function.
Basic Usage
SELECT
NLS_CHARSET_ID('WE8DEC')
FROM dual;
Output:
NLS_CHARSET_ID('WE8DEC')
___________________________
2
Here is another example:
SELECT
NLS_CHARSET_ID('ZHT16DBT')
FROM dual;
Output:
NLS_CHARSET_ID('ZHT16DBT')
_____________________________
862
NULL Parameter
If any of the parameters are NULL
, NLS_CHARSET_ID()
will return NULL
.
SET NULL 'NULL';
SELECT
NLS_CHARSET_ID(NULL)
FROM dual;
Output:
NLS_CHARSET_ID(NULL)
_______________________
NULL
In this example, we use the SET NULL 'NULL';
statement to display NULL
values as the string 'NULL'
.
Conclusion
The Oracle NLS_CHARSET_ID()
is a built-in function that returns the ID corresponding to the given character set name.