Oracle NLS_CHARSET_DECL_LEN() Function
Oracle NLS_CHARSET_DECL_LEN()
is a built-in function that returns the declaration length in characters of an NCHAR
column.
Oracle NLS_CHARSET_DECL_LEN()
Syntax
Here’s the syntax for the Oracle NLS_CHARSET_DECL_LEN()
function:
NLS_CHARSET_DECL_LEN(byte_count, char_set_id)
Parameters
byte_count
-
Required. It is the width of the
NCHAR
column. char_set_id
-
Required. It is the character set ID of the column.
Return Value
The Oracle NLS_CHARSET_DECL_LEN()
function returns the declaration length in characters of an NCHAR
column.
If any of the arguments is NULL
, NLS_CHARSET_DECL_LEN()
will return NULL
.
Oracle NLS_CHARSET_DECL_LEN()
Examples
Here are some examples that demonstrate the usage of the Oracle NLS_CHARSET_DECL_LEN()
function.
Basic Usage
SELECT
NLS_CHARSET_DECL_LEN(200, 1830)
FROM dual;
Output:
NLS_CHARSET_DECL_LEN(200,1830)
_________________________________
100
You can also use the NLS_CHARSET_ID()
function to obtain the character set ID from the name of the character set:
SELECT
NLS_CHARSET_DECL_LEN(200, NLS_CHARSET_ID('ja16eucfixed'))
FROM dual;
Output:
NLS_CHARSET_DECL_LEN(200,NLS_CHARSET_ID('JA16EUCFIXED'))
___________________________________________________________
100
NULL Parameters
If any of the arguments is NULL
, NLS_CHARSET_DECL_LEN()
will return NULL
.
SET NULL 'NULL';
SELECT
NLS_CHARSET_DECL_LEN(2000, NULL) NULL_1,
NLS_CHARSET_DECL_LEN(NULL, 1830) NULL_2,
NLS_CHARSET_DECL_LEN(NULL, NULL) NULL_3
FROM dual;
Output:
NULL_1 NULL_2 NULL_3
_________ _________ _________
NULL NULL NULL
In this example, we use the statement SET NULL 'NULL';
to display NULL
values as the string 'NULL'
.
Conclusion
Oracle NLS_CHARSET_DECL_LEN()
is a built-in function that returns the declaration length in characters of an NCHAR
column.