Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

case and accent insensitive search

623269Oct 16 2008 — edited Oct 21 2008
Hi,
I'm new to PL so sorry if it shows with the post :). I'm trying to do a case and accent insensitive search in Apex without using upper and lower functions. I've found nlssort to solve this but I'm not sure if I'm doing something wrong or it can't be done.

nlssort works fine when used like this:
select *
from Items_V
where nlssort(Name,'nls_sort=spanish_ai') like (nlssort(:P5_Name,'nls_sort=spanish_ai'))
what I also need is results that contain the Name and on top of that a case in the where clause.

The following code is what I have now and _where I want to include the nlssort_. It returns all items matching or containing P5_Name and Null values.
select *
from Items_V
where  ((Name like (case when to_char(:P5_Sel)='1' then nvl('%'||:P5_Name||'%','%' )
                         else '%' end)
        and Name is not null) 
        or ((case when to_char(:P5_Sel)='1' then nvl('%'||:P5_Name||'%','%' )
                 else '%' end) ='%' and Name is null))				 
I've tried many ways but I just can't get the combination right and don't really know where it should go. Trying a more simple approach to start with, I found that concatenating +'%'+ to the nlssort(:P5_Name,'nls_sort=spanish_ai') wasn't returning items that contained, only items that matched.


Thank you in advance,
Marc

BTW, I'm developing on:
DB 11g
Application Express 3.1.1.00.09
This post has been answered by MichaelS on Oct 16 2008
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 18 2008
Added on Oct 16 2008
6 comments
609 views