Open In App

PLSQL | LENGTH4 Function

Last Updated : 04 Feb, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

The PLSQL LENGTH4 function is used for returning the length of the specified string, using UCS4 code points. 
UCS-4 codepoints is a character encoding which allows the representation of each value as exactly four bytes (one 32-bit word). 
UCS-4 represents a possible value between 0 and hexadecimal 7FFFFFFF for each character. 

The char accepted by the LENGTH4 function in PLSQL can be of any of the datatypes such as CHAR, VARCHAR2, NCHAR, NVARCHAR2, CLOB, or NCLOB. 

The value returned by the LENGTH4 function is of datatype NUMBER. 
If char sent in the parameter has datatype CHAR, then the length includes all trailing blanks. If char is null, then this function returns null. 

Syntax: 

LENGTH4( string )

Parameters Used: 

string – It is used to specify the string whose length you want to find out. 

Supported Versions of Oracle/PLSQL: 

  1. Oracle 12c
  2. Oracle 11g
  3. Oracle 10g
  4. Oracle 9i
  5. Oracle 8i

Example-1:  

DECLARE 
   Test_String string(20) := NULL;
   
   
BEGIN 
   dbms_output.put_line(LENGTH4(Test_String)); 
   
END;    

Output:  

NULL 

Example-2:  

DECLARE 
   Test_String string(20) := '';
   
   
BEGIN 
   dbms_output.put_line(LENGTH4(Test_String)); 
   
END;    

Output:  

NULL 

Example-3:  

DECLARE 
   Test_String string(20) := ' ';
   
   
BEGIN 
   dbms_output.put_line(LENGTH4(Test_String)); 
   
END;    

Output:  

1 

Example-4:  

DECLARE 
   Test_String string(20) := 'Geeksforgeeks';
   
   
BEGIN 
   dbms_output.put_line(LENGTH4(Test_String)); 
   
END;     

Output:  

13 

Example-5:  

DECLARE 
   Test_String string(20) := ' Geeksforgeeks ';
   
   
BEGIN 
   dbms_output.put_line(LENGTH4(Test_String)); 
   
END;     

Output:  

15 

 


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads