Selecting LENGTHB of an NVARCHAR2 does not return the byte length
Last updated on APRIL 24, 2018
Applies to:Oracle Forms - Version 10.1.2 to 184.108.40.206.0 [Release 10.1.2 to 12.2]
Information in this document applies to any platform.
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';
text_io.put_line('Byte length of c2 is '||lengthb(c2));
text_io.put_line('Char length of c2 is '||lengthc(c2));
Byte length of c2 is 5
Char length of c2 is 5
The number of bytes should be 10 in this case.
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 hundreds of Community platforms