Solved

Case insensitive search in Oracle

Posted on 2003-10-30
7
1,134 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 7

Accepted Solution

by:
grim_toaster earned 125 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 125 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

Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.
Suggested Courses

631 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