Oracle / PLSQL: UPPER Function
This Oracle tutorial explains how to use the Oracle/PLSQL UPPER function with syntax and examples.
Description
The Oracle/PLSQL UPPER function converts all letters in the specified string to uppercase. If there are characters in the string that are not letters, they are unaffected by this function.
Syntax
The syntax for the UPPER function in Oracle/PLSQL is:
UPPER( string1 )
Parameters or Arguments
- string1
- The string to convert to uppercase.
Returns
The UPPER function returns a string value.
Note
- See also the LOWER function.
Applies To
The UPPER function can be used in the following versions of Oracle/PLSQL:
- Oracle 12c, Oracle 11g, Oracle 10g, Oracle 9i, Oracle 8i
Example
Let's look at some Oracle UPPER function examples and explore how to use the UPPER function in Oracle/PLSQL.
For example:
UPPER('A quick brown fox jump over a lazy dog') Result: 'A QUICK BROWN FOX JUMP OVER A LAZY DOG' UPPER('this is in upper') Result: 'THIS IS IN UPPER'
Frequently Asked Questions
Question: How do you incorporate the Oracle UPPER function with the LIKE condition? I'm trying to query against a free text field for all records containing the word "test". The problem is that it can be entered in the following ways: TEST, Test, or test.
Answer: To answer this question, let's look at an example.
Let's say that we have a suppliers table with a field called supplier_name that contains the values TEST, Test, or test.
If we wanted to find all records containing the word "test", regardless of whether it was stored as TEST, Test, or test, we could run either of the following SQL statements:
select * from suppliers where UPPER(supplier_name) like ('TEST%');
OR
select * from suppliers where UPPER(supplier_name) like UPPER('test%')
These SQL statements use a combination of the UPPER function and the LIKE condition to return all of the records where the supplier_name field contains the word "test", regardless of whether it was stored as TEST, Test, or test.
No comments:
Post a Comment