Solved

Case insensitive search in Oracle

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

735 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