Oracle String/Char Function - Oracle/PLSQL LENGTH2 Function






This Oracle tutorial explains how to use the Oracle/PLSQL LENGTH2 function.

The Oracle/PLSQL LENGTH2 function returns the length of a string using UCS2 code points.

Syntax

The syntax for the Oracle/PLSQL LENGTH2 function is:

LENGTH2( string1 )

string1 is the string to return the length for. string1 can be CHAR, VARCHAR2, NCHAR, or NVARCHAR2.

string1 can not be CLOB or NCLOB.

If string1 is NULL, LENGTH2 returns NULL.

Example

LENGTH2(NULL)
------------
         NULL
 
 LENGTH2('')
------------
         NULL
 
 LENGTH2(' ')
-------------
            1
 
 LENGTH2('java2s.com')
----------------------
                    9