The Oracle PL/SQL UPPER function is a string manipulation function that is used to convert a given string to all uppercase letters. The function takes a string as input and returns the same string with all characters in uppercase.
Syntax
The syntax for the UPPER function in PL/SQL is as follows:
UPPER(string)
Here, string is the input string that needs to be converted to uppercase.
Example
Let’s take an example to better understand the usage of the UPPER function:
DECLARE my_string VARCHAR2(50) := 'This is a sample string'; BEGIN DBMS_OUTPUT.PUT_LINE('Original String: ' || my_string); DBMS_OUTPUT.PUT_LINE('Uppercase String: ' || UPPER(my_string)); END;
In this example, we have declared a string my_string and assigned it the value ‘This is a sample string’. We have then used the UPPER function to convert this string to uppercase and display the original and uppercase strings using the DBMS_OUTPUT.PUT_LINE function.
The output of the above PL/SQL block would be:
Original String: This is a sample string Uppercase String: THIS IS A SAMPLE STRING
As you can see, the UPPER function has successfully converted all characters in the input string to uppercase.
In summary, the Oracle PL/SQL UPPER function is a very useful string manipulation function that can be used to convert a given string to all uppercase letters. This function can be used in a wide range of scenarios where uppercase strings are required, such as in data validation or in formatting output for reports.