PLSQL | LTRIM Function

The PLSQL LTRIM function is used for removing all specified characters from the left-hand side of a string. The PLSQL LTRIM function accepts two parameters which are input_string and trim_string.

  • If the user does not specify trim_string, it defaults to a single blank.
  • If char is a character literal, then you must enclose it in single quotes.

Oracle Database begins scanning char from its first character and removes all characters that appear in trim_string until reaching a character not in trim_string and then returns the result.

Syntax:



LTRIM( input_string [, trim_string] )

Parameters Used:

  • input_string – It is used to specify the string whose characters need to be trimmed from the left hand side.
  • trim_string – It is an optional parameter which is used to specify the string that will be removed from the left-hand side of string1. If this parameter is omitted, the LTRIM function removes all leading spaces from input_string.

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(25) := '    Geeksforgeeks';
   
BEGIN 
   dbms_output.put_line(LTRIM(Test_String)); 
   
END; 

Output:

Geeksforgeeks 



Example-2:

DECLARE 
   Test_String string(25) := '    Geeksforgeeks';
   
BEGIN 
   dbms_output.put_line(LTRIM(Test_String, ' ')); 
   
END; 

Output:

Geeksforgeeks 



Example-3:

DECLARE 
   Test_String string(25) := '123Geeksforgeeks';
   
BEGIN 
   dbms_output.put_line(LTRIM(Test_String, '123')); 
   
END; 

Output:

Geeksforgeeks 



Example-4:

DECLARE 
   Test_String string(25) := '123123Geeksforgeeks';
   
BEGIN 
   dbms_output.put_line(LTRIM(Test_String, '123')); 
   
END; 

Output:

Geeksforgeeks 



Example-5:

DECLARE 
   Test_String string(25) := '123Geeks123forgeeks';
   
BEGIN 
   dbms_output.put_line(LTRIM(Test_String, '123')); 
   
END; 

Output:

Geeks123forgeeks 


My Personal Notes arrow_drop_up

I am a technology enthusiast who has a keen interest in programming I am pursuing Engineering in Computer Science from GEU, Dehradun I like to unwind by watching movies and English sitcomsI have a keen interest in music

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.