totn Oracle Functions

Oracle / PLSQL: LENGTH2 Function

This Oracle tutorial explains how to use the Oracle/PLSQL LENGTH2 function with syntax and examples.

Description

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

Syntax

The syntax for the LENGTH2 function in Oracle/PLSQL is:

LENGTH2( string1 )

Parameters or Arguments

string1
The string to return the length for. It can be CHAR, VARCHAR2, NCHAR, or NVARCHAR2, but it can not be CLOB or NCLOB.

Returns

The LENGTH2 function returns a numeric value.
If string1 is NULL, then the LENGTH2 function will return NULL.

Applies To

The LENGTH2 function can be used in the following versions of Oracle/PLSQL:

  • Oracle 12c, Oracle 11g, Oracle 10g, Oracle 9i, Oracle 8i

Example

Let's look at some Oracle LENGTH2 function examples and explore how to use the LENGTH2 function in Oracle/PLSQL.

For example:

LENGTH2(NULL)
Result: NULL

LENGTH2('')
Result: NULL

LENGTH2(' ')
Result: 1

LENGTH2('TechOnTheNet.com')
Result: 16

LENGTH2('TechOnTheNet.com ')
Result: 17