Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Case insensitive search in Oracle

Posted on 2003-10-30
7
Medium Priority
?
1,142 Views
Last Modified: 2010-05-18
I know string data comparision in Oracle is case sensitive. Is there a way where can eliminate case sensitive compariision? (we are using 9i)
0
Comment
Question by:rsastry
7 Comments
 
LVL 7

Accepted Solution

by:
grim_toaster earned 500 total points
ID: 9649396
You can convert both strings to upper/lowercase and then do the comparison.  The only thing to watch out for is when you want to use a normal index on the column, as calling a function on it would prevent its use (however, you can use function-based indexes).
0
 

Author Comment

by:rsastry
ID: 9649472
Thanks. Is there a way where we can change server setting without touching the code? (Instead of using upper functions and function based indexes) or is there an option during database install to select case insensitive comparision?
0
 
LVL 7

Assisted Solution

by:Bigfam5
Bigfam5 earned 500 total points
ID: 9649493
Basically the answer is no, but if your app allows for mixed case to be entered then you would have to address that during comparisons

Select * from my_table   where upper(Col1) = 'ABC' ;
OR
Select * from my_table   where lower(Col1) = 'abc';

But like suggested above, create a function based index on Col1

create index idx_my_table_1 on my_table ( upper(Col1) );
OR
create index idx_my_table_1 on my_table ( lower(Col1) );



0
 
LVL 7

Expert Comment

by:Bigfam5
ID: 9649533
Well, if you don't want to touch the code you could always create triggers

create or replace trigger on trg_my_table
before insert or update on my_table
for each row
begin
 :new.Col1 := upper(:new.Col1);
end;
/

0
 
LVL 15

Expert Comment

by:andrewst
ID: 9649566
Yes, you are looking for a feature that SQL Server has (I believe), but unfortunately for you, Oracle does not.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Suggested Courses

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question