My Oracle Support Banner

Selecting LENGTHB of an NVARCHAR2 does not return the byte length (Doc ID 2390023.1)

Last updated on APRIL 24, 2018

Applies to:

Oracle Forms - Version 10.1.2 to 12.2.1.3.0 [Release 10.1.2 to 12.2]
Information in this document applies to any platform.

Symptoms

In PLSQL LENGTHC is a function that returns the length of the specified string using characters. LENGTHB is a function that returns the length of the specified string using bytes instead of characters. 

When trying to select the LENGTHB of an NVARCHAR2 from Forms the value is not accurate. The NVARCHAR2 datatype is used to store Unicode data for specified columns without changing the primary character set of the database. For example:

procedure p is
c2 nvarchar2(10) := 'ABCDE';
begin
text_io.put_line('Byte length of c2 is '||lengthb(c2));
text_io.put_line('Char length of c2 is '||lengthc(c2));
end;

Returns:

Byte length of c2 is 5
Char length of c2 is 5

The number of bytes should be 10 in this case.

Cause

To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!


My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.