Oracle query sort by case sensitive

Hi All,
I am using oracle database 11g.
My use case is I do have a table with following values
Table name -test
product id     productsortdescription
H58098        ACETAMIDOHYDROXYPHENYLTHIAZOLE
043994         Alloy .MM.INTHICK
My query is
select * from test order by productsortdescription;
this query gives result as is like
product id     productsortdescription
H58098        ACETA
product id     productsortdescription
H58098        ACETAMIDOHYDROXYPHENYLTHIAZOLE
043994         Alloy .MM.INTHICK
MIDOHYDROXYPHENYLTHIAZOLE
043994         Alloy .MM.INTHICK
but Expected output/result should be like below:
product id     productsortdescription
043994    
Alloy .MM.INTHICK
H58098      ACETAMIDOHYDROXYPHENYLTHIAZOLE
as All and ACE in productsortdescription
l is in small case than C.
NLS Session parameters are as following
SELECT * from NLS_SESSION_PARAMETERS;
NLS_LANGUAGE    AMERICAN
NLS_TERRITORY    AMERICA
NLS_CURRENCY    $
NLS_ISO_CURRENCY    AMERICA
NLS_NUMERIC_CHARACTERS    .,
NLS_CALENDAR    GREGORIAN
NLS_DATE_FORMAT    DD-MON-RR
NLS_DATE_LANGUAGE    AMERICAN
NLS_SORT    BINARY
NLS_TIME_FORMAT    HH.MI.SSXFF AM
NLS_TIMESTAMP_FORMAT    DD-MON-RR HH.MI.SSXFF AM
NLS_TIME_TZ_FORMAT    HH.MI.SSXFF AM TZR
NLS_TIMESTAMP_TZ_FORMAT    DD-MON-RR HH.MI.SSXFF AM TZR
NLS_DUAL_CURRENCY    $
NLS_COMP    BINARY
NLS_LENGTH_SEMANTICS    BYTE
NLS_NCHAR_CONV_EXCP    FALSE
Please help me out in this scenario.

Are you looking for something like
with
names as
(select 'Etbin' n from dual union all
select 'etbin' from dual union all
select 'ETBIN' from dual union all
select 'ACETAMIDOHYDROXYPHENYLTHIAZOLE' from dual union all
select 'Alloy .MM.INTHICK ' from dual union all
select 'another name' from dual union all
select 'Aalto; Hugo Alvar Henrik' from dual union all
select 'astrerisk' from dual union all
select 'Ezekiel' from dual union all
select 'zylog' from dual
expansion as
(select n,listagg(duo) within group (order by l) ord
   from (select n,level l,
                case when ascii(substr(n,level,1)) between 97 and 122
                     then '0'
                     when ascii(substr(n,level,1)) between 65 and 90
                     then '1'
                     else '2'
                end || substr(n,level,1) duo
           from names
         connect by prior n = n
                and prior dbms_random.random is not null
                and level <= length(n)
  group by n
select n
  from expansion
order by ord
N
another name
astrerisk
etbin
zylog
Aalto; Hugo Alvar Henrik
Alloy .MM.INTHICK
ACETAMIDOHYDROXYPHENYLTHIAZOLE
Etbin
Ezekiel
ETBIN
Regards
Etbin

Similar Messages

  • How to retrieve column names in a query in a case sensitive way

    Given a query, I want to extract all the column names/aliases in the query in a case-sensitive way.
    When I use dbms_sql.describe_columns() or java.sql.ResultSetMetaData classes getColumnName() or getColumnLabel()
    it returns the columns name ONLY in Upper case.
    My application needs to extract the column names in the same case as it appears in the query string.
    Is there any API to get this without parsing the SQL query string?
    Thanks
    PS: The dbms_sql.describe_columns() returns the column name in upper case.
    declare
    IS
    l_column_recs DBMS_SQL.DESC_TAB;
    l_cur NUMBER;
    l_column_count NUMBER;
    BEGIN
    l_cur := dbms_sql.open_cursor;
    dbms_sql.parse(l_cur, 'select target_type from targets', dbms_sql.NATIVE);
    dbms_sql.describe_columns(l_cur, l_column_count, l_column_recs);
    FOR i IN l_column_recs.FIRST..l_column_recs.LAST
    LOOP
    dbms_output.put_line(l_column_recs(i).col_name);
    end loop;
    end;
    /

    As far as the result set is concerned, though, the column name is in all upper case. If you query the data dictionary, you would see that the TARGET_TYPE column in the TARGETS table is stored in upper case.
    The way Oracle works is that column names that are not enclosed in double-quotes are converted to upper case in the data dictionary and elsewhere and then Oracle looks for the column name in the table definition. That is what allows Oracle to have case-insensitive identifiers unless a user specifies case-sensitive identifiers by enclosing the identifier in double quotes.
    If you changed the query to be
    SELECT target_type as "target_type"
      FROM targetsOracle should report the alias in a case sensitive fashion because you've now indicated that the alias should be treated as case sensitive.
    Justin

  • The query screens are case sensitive I want to remove the case sensitivity

    The current query screens are case sensitive ,I want to remove the case sensitivity is there a setting somewhere to remove this or how else can this be done.
    Example:In the restrict value range of the query screen.If we give for a particular field anything in capital letters/small it should take.
    Please let me know ASAP
    Thanks

    Hi pavan,
    generally case sensivity is related to InfoObject Master Data.
    Take a look via Tcode RSD1 to the master data of your InfoObject and check in first screen if flag for capitol letters has been marked.
    If this is the situation it is a problem, because MAster Data in cube have been saved as different if are written like "Letter" or "LETTER".
    Ciao.
    Riccardo.
    Message was edited by:
            Riccardo Venturini

  • Query of queries case sensitive

    Hi,
    I've a question regarding this issue.  I am pulling data from an xml file and dump that data into query of queries then output them.  The problem is when I try to order the query ASC, the upper will be top and the lower will be on the bottom.  Is there a way to sort them before dump data into query?  Or any ways of getting around this?
    Thanks.

    Depending on your requirements, you might want to add a new column to the query, rather than calling upper() on your actual data column... it depends on whether you want your data column to be all upper case (like if you are displaying it).
    So instead of this:
    SELECT col1, upper(col2)
    FROM q
    ORDER BY col2
    Have this:
    SELECT col1, col2, upper(col2) AS col2Sort
    FROM q
    ORDER BY col2Sort
    It doesn't always matter, obviously, but it's handy to keep it in mind.
    Adam

  • Can we write select query regardless of case sensitivity?

    Hello Everyone,
    I have written one function module. And in this FM i am using one import parameter which has Data element and domain as type. In that i have checked Upper/Lower case checkbox, to retain case of the data in table. But when firing query to database i have to supply same case as it is stored in table.
    so, can i ignore the case of the parameter in select query and can i fire the query regardless of the case of the where conition??
    Thanks in Advance,
    Bhavik

    Hi Bhavik,
    You can do this without adding a column to the table.
    Just Fetch all the data in one internal table then loop that table inside that loop check whether that field contains that string or not. For this you use CP operator, that checks for string irrespective of the case. This can perform wild serach also. The following code may help you,
        SELECT * FROM /cpd/d_mp_hdr_s INTO TABLE it_mast_hdr_desc1.
        LOOP AT it_mast_hdr_desc1 INTO wa_mast_hdr_desc.
          IF wa_mast_hdr_desc-text CP lv_mp_text.
            APPEND wa_mast_hdr_desc TO it_mast_hdr_desc.
            CLEAR wa_mast_hdr_desc.
          ENDIF.
        ENDLOOP.
    Here both the internal table and the work area are of type /cpd/d_mp_hdr_s.
    Hope this helps you.
    With Regards,
    Ajeet Pratap Singh

  • Case sensitive within character literals in SQL Server and Oracle

    I am migrating SQL Server database to Oracle database by using Oracle Workbench.
    SQL Server is not case sensitive, but Oracle PL/SQL is case sensitive within character literals. for example, if sort the following string ('UN','Win', 'iS' ,'Ne','zS'), SQL Server will get ('iS', 'Ne','UN','Win','zS') order, but Oracle PL/SQL will return ('Ne','UN','Win','iS','zS') order.
    Anyone has idea how I can get same result as SQL Server without change PL/SQL code (I don't want to change "ORDER BY typename" to "ORDER BY UPPER(typename)" for every stored procedure).
    Thanks

    Jimmy,
    alter session set NLS_SORT=West_European;
    is the closest thing I know of, but UPPER() is the only sure way.
    West_European sort order is AaBbCc ... 0123456789
    usually sort order is 0123456789 ABC ... abc ...

  • Oracle is Case Sensitive, can we change this.?

    Hi all,
    As Oracle Data is a Case sensitive.
    but i want to know that,
    is there any way to change this ?
    that is , the data should not be a case sensitive.
    select * from emp where ename = 'smith';
    Even the SMITH is in caps. it should return that records for the above query.
    Thanks.
    GowriShankar.N

    As a one off for queries you can use the UPPER and LOWER functions, ie;
    select * from emp where LOWER(ename) = 'smith';

  • How to make oracle is case insentive ( not case sensitive)

    SqlServer by default is NOT case sensitive (data content) while Oracle by default is case sensitive (data content).
    please help me to give the solution
    How to make oracle is case insentive ( not case sensitive)
    if there is anyway to make Oracle behave like SqlServer changing NLS settings or any other Oracle settings?
    I have solution for application level . it is working fine
    Possible solutions:
    1. You want to store data case insensitive: do an 'insert...
    values(upper('Abcd'))...'.
    This will put your data in upper case into the tables.
    2. Your data will be mixed-case and you want to select them case
    insensitive:
    create 'function based indexes' on every column you want to use in
    your where-clauses.
    Then 'select ... where <column_name> = 'ABCD'.

    What version of Oracle? Oracle 10g has a capability that can toggle this feature on and off at the session level. Prior versions do not.
    For prior versions you usually have to make use of the upper and/or lower functions in your queries. Sometimes a function based index, FBI, is used to handle this.
    HTH -- Mark D Powell --

  • CASE Sensitivity in Oracle

    Hi,
    I have a situation where I need to have the data in the Oracle 9 DB as case sensitive (which is the default setting in Oracle) ,but, I need to have case insensitive searches.
    Lets say I have data in a column like for example "apple". If the user enters "APPLE" or "Apple" or "apPLe", a match should be found.
    I am concerned at using the below trick because it can lead to a table scan when NLS_SORT is not binary.
    ALTER SESSION SET NLS_COMP=ANSI;
    ALTER SESSION SET NLS_SORT=GENERIC_BASELETTER;
    Thanks,
    Sridhar

    Like wise, you can also create a functional index (called Linguistic Index) in Oracle to support the cases when NLS_SORT <> Binary.
    For example:
    CREATE INDEX NLS_GENERIC_BASELETTER ON product
    (NLSSORT(product_name, 'NLS_SORT=GENERIC_BASELETTER'));

  • Can we ignore the case-sensitivity

    Suppose my table has a column of varchar datatype and I have inserted data in uppercase or lowercase or in mixed case.
    If I want to fire select query then I'll have to take care of the case.Is there any way so that we can ignore the case sensitivity of the database and we can fire select queries without considering case of the data?
    In other words,
    Is there is any option available in Oracle to bypass case sensitive configuration while retrieving output from oracle query. Oracle does not return output if data in table are in capital letters and query to retrieve data contains value in title case or lower case.An option to deal with such case is to use upper function in oracle query however would be more interested in knowing if there is any option available in oracle to bypass the case sensitive check while retrieving output from query, as it works with SQL.

    There're some bugs associated with putting NLS_COMP=LINGUISTICS and NLS_SORT=BINARY_CI
    The metalink note id says something about these bugs:
    Doc ID:Note:5252496.8
    Doc ID:Note:3945156.8
    Doc ID:Note:4996004.8
    Doc ID:Note:5464341.8
    Doc ID:Note:5718815.8

  • Case sensitive column name problem

    I have a strange problem in my application.
    I install the application on several machines with no problem but in one machine I'm getting an exceptions on:
    "Column 'SomeColumnName' does not belong to table"
    the code look like this:
    DataRow newDataRow = myTableFromDatabase.NewRow();
    newDataRow["SomeColumnName"] = dr["SomeColumnName"];
    when I change the code to upper case:
    DataRow newDataRow = myTableFromDatabase.NewRow();
    newDataRow["SOMECOLUMNNAME"] = dr["SOMECOLUMNNAME"];
    it works on the problematic machine.
    - I got the same problem on reading data from OracleDataReader.
    - The property DataTable.CaseSensitive was not changed (default = false).
    I'm not sure this is ODP problem or .net but I can't find any .net issues on that.

    Ok ,
    This is the most bizar bug that I ever saw:
    The problem was that the machine was running in turkey.
    In .NET culture settings the function ToUpper is not work on the letter 'i' when the region is turkey.
    That means that oracle ODP OracleDataReader is case sensitive on the column name - if the column name have the letter 'i'.

  • Can a LOV popup search be made case sensitive?

    Can a LOV popup based on a SQL table query be made case sensitive. By default it looks like it is case insensitive by the text on the popup.

    I think you might need to look at doing some customization to your custom managed properties , you can manipulate the values within the managed properties by mapping them to single values  check custom content processing 
    http://msdn.microsoft.com/en-us/library/office/jj163968(v=office.15).aspx
    Hope that helps|Amr Fouad|MCTS,MCPD sharePoint 2010

  • Problem in XI - JDBC (oracle) Scenario, case sensitive column name

    I had a XI -> JDBC scenario, connecting to a SQL server, where the query was being generated using Message Mapping (XML SQL Format),
    now the database has been migrated from SQL server to Oracle, and we are using the same XI scenario, but now the problem is, the query generated using message mapping doesnt work because it seems the query (UPDATE statement) requires the field name as having All capital letters, i mean the Column name in query to Oracle has become case sensitive,
    can u help me out

    Hi
    Oracle doesnt have restriction that Query has to be in uppercase for any column. But it is good go use Upper case for the Query.
    Use oracle editor to do the query if it is working fine and then use XML SQL in XI
    Check this thread SAP has given some
    http://help.sap.com/saphelp_nw04s/helpdata/en/43/68a541a1166153e10000000a1553f6/frameset.htm
    Check FAQ on the JDBC adapter, see SAP Note 831162
    always useful Note
    Thanks
    Gaurav

  • Case-sensitive values in an Tabular Model with a Oracle Datasource

    Hi,Lets use an Oracle Database as Datasource for my Project. I use a "Select distinct ColumnA from Table" to build up a LookupTable in my Tabular Model. But it returns Dublicates!! eg:
    When I fire the query from Oracle SQL Developer I got 2 Records "1N" and "1n". In the Grid View in SSDT I see 2 times "1N". ??
    Collation Case Sensitive. OK, but how to solve that?
    KR

    Hi KR,
    According to your description, you encounter the case-sensitive issue when creating SQL Server Analysis Services Tabular model project, right?
    Based on my research, Tabular models have the insensitivity problem by default. The workaround for this issue is creating a empty tabular model in tabular server using the xmla below and import the tabular in SSDT.
    <Create xmlns="http://schemas.microsoft.com/analysisservices/2003/engine">
    <ObjectDefinition>
    <Database xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ddl2="http://schemas.microsoft.com/analysisservices/2003/engine/2" xmlns:ddl2_2="http://schemas.microsoft.com/analysisservices/2003/engine/2/2" xmlns:ddl100_100="http://schemas.microsoft.com/analysisservices/2008/engine/100/100" xmlns:ddl200="http://schemas.microsoft.com/analysisservices/2010/engine/200" xmlns:ddl200_200="http://schemas.microsoft.com/analysisservices/2010/engine/200/200" xmlns:ddl300="http://schemas.microsoft.com/analysisservices/2011/engine/300" xmlns:ddl300_300="http://schemas.microsoft.com/analysisservices/2011/engine/300/300">
    <ID>Collation test</ID>
    <Name>Collation test</Name>
    <Language>1033</Language>
    <Collation>Latin1_General_CS_AS</Collation>
    <DataSourceImpersonationInfo>
    <ImpersonationMode>Default</ImpersonationMode>
    </DataSourceImpersonationInfo>
    <ddl200_200:StorageEngineUsed>InMemory</ddl200_200:StorageEngineUsed>
    <ddl200:CompatibilityLevel>1100</ddl200:CompatibilityLevel>
    </Database>
    </ObjectDefinition>
    </Create>
    For the detail information about it, please refer to the link below.
    http://blogs.msdn.com/b/cathyk/archive/2011/10/24/making-tabular-models-more-sensitive.aspx
    Regards,
    Charlie Liao
    If you have any feedback on our support, please click
    here.
    Charlie Liao
    TechNet Community Support

  • Hibernate for lower case data(case sensitive) in oracle 10G

    Hi,
    I generated my data (oracle 10G release 2) using lowercase data types and table names. This requires queries in the strict form of -
    Select "Column_Name" from "Table_name";
    But Hibernate makes the queries as -
    Select Column_Name from Table_Name;
    driver I am using is oracle.jdbc.driver.OracleDriver
    Jar is ojdbc14
    and dialect is org.hibernate.dialect.Oracle9Dialect
    The problem is:
    table or view does not exist.
    as it(lower case data) does not recognize the hibernate query format.
    Can anyone suggest the proper driver and Jar to overcome the problem.
    Regards,
    Ankit

    Ankit,
    Just bite the bullet and don't use case-sensitive identifiers :-)
    I don't use "hibernate", but maybe you can add the double-quotes -- " -- in the XML file?
    I don't think there's a JDBC driver that adds the double-quotes for you. So I think your only option (if you insist on using case-sensistive identifiers) is to explore possibilities through "hibernate" itself.
    I also don't think there's any database setting that allows Oracle to accept case-sensitive identifiers.
    Good Luck,
    Avi.

Maybe you are looking for