Built-In Functions in PL/SQL
Built-In Functions in PL/SQL
PL/SQL contains various built-in functions to work with strings and date datatype. Here we are going to see
the commonly used functions and their usage.
Conversion Functions
These built-in functions are used to convert one datatype to another datatype.
Output: 1234
String Functions
These are the functions that are used on the character datatype.
SUBSTR ( text, start, text – main string select substr(‘PLSQL,1,2) from dual
length) start – starting position Output: PL
length – length to be sub stringed
Output: My Story
Select LENGTH (‘guru99’) from dual;
LENGTH ( text ) Returns the length of the given string
Output: 6
Select LPAD(‘guru99’, 10, ‘$’) from
LPAD ( text, length, Pads the string in the left side for the given length (total
dual;
pad_char) string) with the given character
Output: $$$$guru99
RPAD (text, length, Pads the string in the right side for the given length (total Select RPAD(‘guru99′,10,’-‘) from dual
pad_char) string) with the given character Output: guru99—-
Select LTRIM(‘ Guru99’) from dual;
LTRIM ( text ) Trims the leading white space from the text
Output: Guru99
Select RTRIM(‘Guru99 ‘) from dual;
RTRIM ( text ) Trims the trailing white space from the text
Output; Guru99
Date Functions
These are functions that are used for manipulating with dates.