Case insensitive selects with 'like'

I use a 10g database (10.2.0.2 same behaviour with 10.2.0.1). What we want is case insensitive selects with 'like' operator in the where clause. NLS_COMP is set to 'LINGUISTIC' and NLS_SORT is set to 'BINARY_CI.
In a table we have two columns one of type 'varchar2' one of type 'nvarchar2'. The databases national character set is set to UTF8. Case insensitive sorting works with both columns. Select statements with '.... where varchar2col like '%r%' returns also values with upper case 'R' values (that is what I expect).
The select statements with '.... where nvarchar2col like '%r%' however does not return the row with upper case 'R' values.
I used SQL*Plus: Release 10.2.0.3.0 and other clients and the behaviour is the same so
I think it is not client related.
Is that a known issue or is there any other parameter to set for UTF8 nvarchar columns?
Any hint is very much appreciated! Here are the nls settings in database, instance and session:
DPARAMETER      DVALUE IVALUE SVALUE
NLS_CHARACTERSET WE8ISO8859P1
NLS_COMP      BINARY LINGUISTIC LINGUISTIC
NLS_LANGUAGE      AMERICAN AMERICAN AMERICAN
NLS_NCHAR_CHARACTERSET UTF8
NLS_RDBMS_VERSION 10.2.0.1.0
NLS_SORT BINARY BINARY_CI BINARY_CI
NLS_TERRITORY      AMERICA AMERICA AMERICA

OK. Found out what the problem is. It is obviously the client.
While using the instant client and setting the parameters (NLS_SORT=BINARY_CI and NLS_COMP=LINGUISTIC) as environment variables does not work correctly, at least not for nvarchar2 fields. The nls_session_parameters show the correct values, but selects with 'like' operators in the where clause do not return case insensitive. Issuing the 'alter session' commands and again setting the nls parameters solves the problem.
Using the full client installation also works, in case the parameters are set in the registry on windows systems. With the full client it it not necessary to issue the 'alter session' commands again.
So obviously the problem is instant client and nvarchar2 field related. That's too bad....

Similar Messages

  • Case-insensitive Search with Search Form

    I am using a Search Form with a UIX Page. One of the issue that need to be resolved is to be able to do case-insensitive search for text information stored in some database columns. Please advise me how to implement case_insensitive search with JDeveloper's Search Form.
    Thanks in advance,

    Hi Qian,
    This article (below) by Steve Muench explains how you can customize Query by example behaviour of ADF BCs and if you really want, how to create your own ViewCriteriaAdapter (but you don't have to go quite that far - luckily :) ).
    http://radio.weblogs.com/0118231/2005/02/10.html#a492
    Here is what I did. I implemented the following method in my base view object class (MyBaseViewObject). Note that this code is based on a piece of code that Steve posted on his blog (http://radio.weblogs.com/0118231/stories/2003/07/11/implementingAViewCriteriaAdapterToCustomizeQueryByExampleFunctionality.html); originally an example about creating your own ViewCriteriaAdapter.
    Since applyViewCriteria(oracle.jbo.ViewCriteria) is used by the query-by-example mechanism you're able to "intercept" the ViewCriteria on "it's way in". After that the standard ViewCriteria does it's job as ususal and generated the where clause when required.
    public void applyViewCriteria(ViewCriteria vc)
         if( null == vc || vc.size() == 0 ) super.applyViewCriteria(vc);
         ViewCriteriaRow criteriaRow = (ViewCriteriaRow)vc.first();
         StructureDef def = criteriaRow.getStructureDef();
         AttributeDef[] attrs = def.getAttributeDefs();
         System.out.println(getClass().getName() + ": applyViewCriteria()");
         boolean bFirst = true;
         do{
           if(vc.hasNext() && !bFirst) criteriaRow = (ViewCriteriaRow)vc.next();
           criteriaRow.setUpperColumns(true);
           for (int j = 0, attrCt = attrs.length; j < attrCt; j++)
             String criteriaAttrVal = ((String)criteriaRow.getAttribute(j));
             if (criteriaAttrVal != null && !criteriaAttrVal.equals("") && !JboTypeMap.isNumericType(attrs[j].getSQLType()))
              criteriaRow.setAttribute(j,criteriaAttrVal.toUpperCase());
           bFirst=false;
         }while(vc.hasNext());
         super.applyViewCriteria(vc);
    NOTE that doing this makes all your views case insensitive (to vc search) you may want to implement more functionality in your base view object to set whether a view is in case insensitive mode or not.
    ALSO that flag will not be passivated (if I remember correctly - someone correct me if I'm wrong) so you'll have to add that flag to the passivated data.
    Cheers!
    Sacha

  • Select with like for multiple results

    Hi,
    I need to find all the rows of a table that contain the values of another query in the table.
    My problem is that the table that I want to verify may contain a list of values and I’m not been able to think on an easy way to do this!
    Performance is also an issue because my table2 will have only a short list of values to look for but the table I will search will have a few million rows.
    The field that I need to search is a “VARCHAR2(4000 BYTE)” It is not indexed but probably I will need to create an index in it in case the best solution involves it!
    My example scenario:
    CREATE TABLE TEST_TABLE
    (id number,
    COL1 CHAR(25));
    CREATE TABLE TEST_TABLE2
    (COL1 CHAR(25));
    insert into TEST_TABLE (id,COL1) values (1,'1;2;3');
    insert into TEST_TABLE (id,COL1) values (2,'1');
    insert into TEST_TABLE2 (COL1)  values ('1');
    insert into TEST_TABLE2 (COL1) values ('2');
    select id from TEST_TABLE
    where (col1) in ( select col1 from TEST_TABLE2)My results with this are:
    Results:
    ID
    2I need the results to be ( because ID 1 also contains the values from table 2):
    Results:
    ID
    1
    2Thanks 
    Ricardo Tomás

    select  id
      from  test_table t1
      where exists (
                    select  1
                      from  test_table2 t2
                      where ';' || trim(t1.col1) || ';' like '%;' || trim(t2.col1) || ';%'
            ID
             1
             2
    SQL> Why column COL1 is defined as CHAR? Since CHAR is right blank padded you will have to trim. Use VARCHAR2:
    SQL> select  id
      2    from  test_table t1
      3    where exists (
      4                  select  1
      5                    from  test_table2 t2
      6                    where ';' || t1.col1 || ';' like '%;' || t2.col1 || ';%'
      7                 )
      8  /
            ID
             1
             2
    SQL> SY.

  • How do I make a case-insensitive comparison with PHP?

    This is what I have tried so far:
    if (strcasecmp($var, "ComparedString") == 0)
    $error = 1;
    ...but it doesn't seem to work.

    You are looking to see if they are equal? Your code should
    work to set
    $error to true/1 if the two are equal. Is it not doing this?
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    ==================
    "AngryCloud" <[email protected]> wrote in
    message
    news:fkbm59$g70$[email protected]..
    > This is what I have tried so far:
    >
    > if (strcasecmp($var, "ComparedString") == 0)
    > {
    > $error = 1;
    > }
    >
    > ...but it doesn't seem to work.

  • Search * from t where a like b case-insensitive ?

    I have a Database-field (CHAR60) that contains text with upper and lower case letters. In my application, the user can search for entries in the DB table using this field, which leads to an SQL statement like this:
    SELECT * FROM table WHERE field LIKE pattern INTO...
    My question:
    If I search for "abc", i won't find entries with "aBc". Can I do a case-insensitive search with SELECT and LIKE?

    Hello Daniel,
    What is the domain(CHAR60) for the field that you are searching for?
    The domain has an attribute called <i>Lowercase</i>, and it is my understanding that so long as this is checked, the data will be stored in the database exactly like it was entered on the screen (case-sensitive).
    If thst is the case with your domain, then I guess you would have to make do with something like:
    SELECT *
      FROM table.
      TRANSLATE : TABLE-FIELD TO UPPERCASE,
                  PATTERN TO UPPERCASE.
      IF TABLE-FIELD CS PATTERN.
    *    Do your processing here...or fill the internal table
      ENDIF.       
    ENDSELECT.
    I know this code has been a bit crude, but this is the essence.
    Regards,
    Anand Mandalika.

  • Intermittent oracle errors with case-insensitive searches

    Hi
    I have a table with several columns, two of them are indexed with oracle text.
    When I ask queries containing "CONTAINS"-clauses against these columns everything works great. However I have a few other columns in table that I want to run case-insensitive comparisons with.
    So I enable case-insensitivity:
    ALTER SESSION SET NLS_COMP=LINGUISTIC
    ALTER SESSION SET NLS_SORT=BINARY_CI
    Now I suddenly start getting intermittent errors.
    When I call a query:
    SELECT
    FROM
    article_table at
    WHERE
    CONTAINS(searchfield , '%MEAT%') > 0
    Sometimes it works, but sometimes I get:
    ERROR
    ORA-29902: ett fel inträffade när rutinen ODCIIndexStart() kördes
    ORA-20000: Oracle Text error:
    DRG-00100: internal error, arguments : [50935],[drpn.c],[1051],[],[]
    DRG-00100: internal error, arguments : [50935],[drpnw.c],[601],[],[]
    DRG-00100: internal error, arguments : [51002],[drwa.c],[594],[],[]
    DRG-00100: internal error, arguments : [51028],[drwaw.c],[297],[0],[%MEAT%]
    DRG-00100: internal error, arguments : [50401],[dreb.c],[1033],[],[]
    ORA-00600: intern felkod, argument: [qernsRowP], [1], [], [], [], [], [], []
    Anyone knows what is going on? Is this bug? Is there a fox for it?
    Thanks for any help anyone can provide.
    /Kjell

    Clearly that's a bug. Unless anyone here recognizes it and can point you to the bug/patch number I would strongly recomend you to take it to oracle support.
    Incidently, doing a search for '%MEAT%' is usually a bad idea. Leading wildcards will disable the use of the index on the $I table, so unless you're using the SUBSTRING_INDEX option such searches will usually perform very badly. They shouldn't cause "internal errors", of course.

  • SAP JPA - case-insensitive search

    Hi there, is it possible to have a case-insensitive search with SAP JPA? The keywords UPPER, LOWER aren't available in the query (OpenSQL limitation I guess).
    The only way I see is to create a duplicates columns for the search relative atributes and make the data upper or lower case before save. May be there is another options? More suitable and elegant?

    Hi,
    you may bypass openSQL by native queries.
    Make sure that you use the hint described in
    http://help.sap.com/saphelp_nwce72/helpdata/en/4a/0cf02870c540caab611d56220ec0cb/frameset.htm
    together with createNativeQuery.
    But anyway, the approach with duplicates columns enables you to create indexes on these UPPER columns. It is not too bad.
    Regards,
    Rolf

  • Case Insensitive Search coupled with "LIKE" operator.

    Greetings All, I am running Oracle 11gR1 RAC patchet 25 on Windows X64.
    This db supports and application that requires case insensitive searches.
    Because there are a few entry points into the db I created an "after login" trigger:
    CREATE OR REPLACE TRIGGER MyAppAfterLogon_TRGR
    AFTER LOGON
    ON DATABASE
    DECLARE
    vDDL VARCHAR2(200) := 'alter session set nls_comp=''linguistic''';
    vDDL2 VARCHAR2(200) := 'alter session set nls_sort=''binary_ci''';
    BEGIN
    IF ((USER = 'MyAppUSER') OR(USER = 'MyAppREPORTINGUSER')) THEN
    EXECUTE IMMEDIATE vDDL;
    EXECUTE IMMEDIATE vDDL2;
    END IF;
    END MyAppAfterLogon_TRGR;
    This ensures that everyone connecting to the DB via any mechanism will automatically have case insensitive searches.
    Now, to optimize the know queries I created the standard index to support normal matching queries:
    select * from MyTable where Name = 'STEVE';
    The index looks like:
    CREATE INDEX "CONTACT_IDX3 ON MYTABLE (NLSSORT("NAME",'nls_sort=''BINARY_CI'''))
    This all works fine, no issues.
    The problem is when I write a query that uses the "LIKE" operator:
    select * from MyTable where Name like 'STEV%';
    I get back the record set I expect. However, my index is not used? I can't for the life of me get this query to use an index.
    The table has about 600,000 rows and I have run gather schema stats.
    Does anyone know of any issues with case insensitive searches and the "LIKE" clause?
    Any and all help would be appreciated.
    L

    I think there is issue with your logon trigger :
    "IF ((USER = 'MyAppUSER') OR(USER = 'MyAppREPORTINGUSER')) THEN"
    it should be :
    IF UPPER(USER) = 'MYAPPUSER' OR UPPER(USER) = 'MYAPPREPORTINGUSER' THEN
    because user name stored in Upper case. Check and try.
    HTH
    Girish Sharma

  • Like Query with Case insensitive

    Hi ,
    I have select query with Like, need to add case insenstive for that.
    E.g
    Select * from emp where empname like ('D%').
    The above query will fetch only names starting with 'D' not the name starting with 'd'.But i need to fetch all the name starting with D or d. Can anyone help me out with this query.
    Thanks
    Durai

    Hi
    Use uppercase for example:
    Select * from emp where upper(empname) like ('D%');
    Ott Karesz
    http://www.trendo-kft.hu

  • SELECT Query to get the Values in Case insensitive Format

    Hi ,
    This is hari,
    I want to select the user name in a table ex: username="HARI" or username='Hari' or username="HaRi" like this
    If i wrote the query like
    select username from userdb where username="Hari";
    it is displaying the records which only matches "Hari" only .
    can anybody help me out on this query asap please....
    the query should return all the results
    which matches any of the following strings as inputs "HARI" or "HaRi" or "hAri" or the like.
    Awaiting for Response,
    Thanks & Regards
    Hari

    Another solution is setting NLS_SORT to CI - case insensitive (or whatever_your_language_is_CI) and NLS_COMP to ANSI:
    SQL> with t as (
      2             select 'HARI' name from dual union all
      3             select 'Hari' name from dual union all
      4             select 'HaRi' name from dual
      5            )
      6  select  *
      7    from  t
      8    where name = 'hArI'
      9  /
    no rows selected
    SQL> alter session set nls_sort = binary_ci
      2  /
    Session altered.
    SQL> alter session set nls_comp=ansi
      2  /
    Session altered.
    SQL> with t as (
      2             select 'HARI' name from dual union all
      3             select 'Hari' name from dual union all
      4             select 'HaRi' name from dual
      5            )
      6  select  *
      7    from  t
      8    where name = 'hArI'
      9  /
    NAME
    HARI
    Hari
    HaRi
    SQL> SY.

  • Search on text with diacritic, and case insensitive

    Hello to all,
    I'm using this condition in a query on XML:
    field[contains(@value, "gangesa" )
    If @value= 'Gaṅgeśa' I'd like to get this record also by using the word: "gangesa" So I need to map:
    ṅ = n
    ś = s
    And do it in case insensitive. Somebody can help me?
    Thank you,
    Cristian                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    ALTER SESSION SET NLS_COMP=LINGUISTIC;
    ALTER session set nls_sort='binary_ai'; -->accent insensitive
                 binary_ci -->case insensitive.
    with t as
    (select 'Gageśa' col1 from dual union all
    select 'GAgEśa'  from dual union all
    select 'gagEśA'  from dual union all
    select 'not Gageśa' from dual
    select * from t where col1 like '%gagesa';
    Gagesa
    GAgEsa
    gagEsA
    not Gagesaand do the search.
    Edited by: PhoenixBai on Aug 25, 2010 10:14 PM

  • Making ADF Search case insensitive without using Execute with Params??

    I have a ADF search page baed on VO. I'm not Execute with Params form, instead i'm using normal ADF search page. Is it possible to make the search case insensitive?? if yes, how to do that?

    Ok, i'll try to find out the SRDemo application using ADF BC.
    And In Execute with params form,i'm already using UPPER on both the sides of where clause.
    Say my VO query is like
    select <table name>,...
    from fnd_tables t,fnd_applications a
    where a.application_id = t.application_id
    and upper(t.table_name) like upper(:EntityName) || '%'
    Then i created the ADF paramaters form by dragging and dropping the Execute with param from data control pallette.. when i run this page and do the search, it throws the error given in my second update...Any clue why that error is coming?
    Thanks
    Senthil

  • Case insensitive search in select statement

    Hi Experts,
      I have entries in table as mixed case. For example i am searching on an attribute called description in the table. I want the serch to be case insensitive for that attribute. Because in table it is i.e. JUMBO Pack and in the search attribute it is i.e. Jumbo Pack.
    I do not want to translate both to the same case and search. Is there an option?
    Best Regards!
    Sandip

    Hi Sandip,
    One more alternative:
    If ztext is ur original field which is saving the mixed text.
    Append one extra field(ztext_upper) to the table.
    Now if " Sap Sdn" is the text we are saving then
    While saving the entires to the table,
    1. asusual save the value(" Sap Sdn") to teh original field(ztext)
    2. translate the value to upper case(SAP SDN) and save this entry to teh newly appended field(ztext_upper)
    Now while doing search, translate to upper case and compare with the value in ztext_upper. If it satisfies then for display options select the original value from the field (ztext) which is corresponding to the satisfied ztext_upper field.
    Regards,
    Swarna Munukoti.

  • LC_COLLATE with dotfiles at top, then case-insensitive sorting

    Hello,
    I would like to have the following sort order in file managers or when using the "ls" command:
    1. dotfiles should be on top
    2. other files should follow but case-insensitive
    For (1) LC_COLLATE=C works, but it then sorts the remaining file case-sensitive
    For (2) e.g. LC_COLLATE="en_US.UTF-8" or de_DE.UTF-8 works.
    Is there a locale that fits to my needs? If not, is it possible to edit a locale or create custom rules?
    Thank you!

    Y = Opportunity Revenue
    X = Month
    The report is a 4-month forecast, but not using built-in Forecasting that CRMOD uses; this report uses the Forecast checkbox in an opportunity to determine if the oppty should be on the forecast report, then grabs the overall Oppty Revenue from that same region of the Oppty (not using line/Product level revenue field).
    The report uses a table and above that a chart with 3D cylindrical output where each press model (derived from a field in the Oppty header) is a different color (I'm letting Analysis defaults set the colors for each product).
    My boss wants to sort the colors from smallest model size to largest model size for consistency sake and to make the chart easier to comprehend with a glance.
    Is this even possible? I could see sorting by revenue size, but that's not always the best indicator (as some used larger presses may sell for less than new smaller ones).
    Any ideas?
    Thanks,
    Andy

  • SELECT INTO doing case insensitive query?

    Hi all,
    I'm having a problem with a query acting as if it is case-insensitive when I do a "SELECT table.x INTO variable ...". If I do the same query, without the "INTO variable", I get one result, as expected.
    The query is similar to the following:
    SELECT table_id INTO variable FROM table WHERE table.varchar2column = 'name' AND table.integercolumn = int_variable;
    There is a unique constraint forcing the varchar2column / integercolumn values to be unique.
    If the varchar2column has two entries that differ only in case, a regular select statement returns one result. However, in the stored procedure using the INTO, I get the following error message:
    ORA-01422: exact fetch returns more than requested number of rows
    It does not get that if I remove the entry that differs only in letter-case. This is Oracle 10.2.0.1.0, if that matters.
    I need this query to be case sensitive. I'm not a DB expert, I'm just a developer trying to fix a problem. I attempted to run "ALTER session SET nls_sort = binary" in the stored procedure, but I guess I can't do that...
    Any suggestions would be appreciated.

    791307 wrote:
    SELECT table_id INTO variable FROM table WHERE table.varchar2column = 'name' AND table.integercolumn = int_variable;
    ...When you say, "...AND table.integercolumn = int_variable;" What is the name of int_variable? Does that name match some column name? Could you post the table creats and a complete sample PL/SQL block with your issue?
    One of the things that gets me every once in awhile is having a variable name that matches a column name. In that case the column name is used inside the select statement, not the variable. To avoid that issue, I use v_ for all my variables. (Others have different standard prefixes.)
    I only point this out, because it might be given results that look case insensitive on the varchar2 column, but is really an issue with the integer column matching to a variable:
    SQL> drop table T;
    Table dropped.
    SQL> create table T (id number constraint T_PK primary key
      2      , Varchar2Data varchar2(20)
      3      , NumberData number(38)
      4      , constraint T_UK1 unique (Varchar2Data, NumberData)
      5  );
    Table created.
    SQL> insert into T values (1, 'STRING', 100);
    1 row created.
    SQL> insert into T values (2, 'string', 200);
    1 row created.
    SQL> insert into T values (3, 'STRING', 300);
    1 row created.
    SQL> select * from T where Varchar2Data = 'STRING' and NumberData = 100;
            ID VARCHAR2DATA         NUMBERDATA
             1 STRING                      100
    SQL> declare
      2      NumberData number(38);
      3      Id Number;
      4  begin
      5      NumberData := 100;
      6      select Id into Id
      7      from T
      8      where T.Varchar2Data = 'STRING'
      9      and T.NumberData = NumberData;
    10      DBMS_OUTPUT.PUT_LINE(Id);
    11  end;
    12  /
    declare
    ERROR at line 1:
    ORA-01422: exact fetch returns more than requested number of rows
    ORA-06512: at line 6
    SQL> declare
      2      v_NumberData number(38);
      3      v_Id Number;
      4  begin
      5      v_NumberData := 100;
      6      select Id into v_Id
      7      from T
      8      where T.Varchar2Data = 'STRING'
      9      and T.NumberData = v_NumberData;
    10      DBMS_OUTPUT.PUT_LINE(v_Id);
    11  end;
    12  /
    1
    PL/SQL procedure successfully completed.
    SQL>

Maybe you are looking for

  • Error in setting permissions of file/directory

    This is the error I am getting Error in setting permissions of file/directory /u01/app/oracle/jre/1.1.8/bin/i686/native_threads/.extract_args I am running RedHat 9 and obviously installing 9.2.0. Any ideas on why I might be getting this. I have set p

  • How do I delete these songs that came in my music on iPhone 5s?

    I want to delete these songs that came pre-loaded on my iphone and I can't seem to do it the same way I did on my 3Gs.  Also I can't seem to get all my music to load on my new iPhone either.

  • How to save a .csv file to database server

    Hi every body, I need to upload a .csv file from the client machine and save it to a directory in a database sever. I could do the uploading part. Can anyone tell me how to save the file? Another option is save the file as a CLOB in a database column

  • Displaying Content in Flex - Best Practice

    I'm curious as to people's thoughts for the best methods to display content in Flex. In particular, I'm creating a UI and want one of the first panels that is displayed to the user to display some simple instructions on how to use the UI. Should I im

  • The Submit button does nothing.  How can this problem be corrected?

    I have seen numerous postings stating that a Submit button on an XFA form will not work.  I believe this may be a widespread problem.  The symptoms are as follows: 1. The form is a Designer form (sometimes referred to as an "XFA form") that contains