Solved

Case insensitive search in Oracle

Posted on 2003-10-30
7
1,110 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 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
Via a live example, show how to take different types of Oracle backups using RMAN.
This video shows how to recover a database from a user managed backup

911 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now