Sort problem in a sql statement with Order by clause

Hello,
I execute this statement :
Select keyart from article order by keyart desc;
and i got this result :
KEYART
VI-ZFI/GN
VI-WWAD110
VI-WV83
VI-WVLZ816
VI-WVLZ811
VI-WVLP6
VI-WVLA9C3
VI-WVLA4R5
VI-WVLA2.8
VI-WVLA12B
VI-WVD9N
KEYART
VI-WVCP210
VI-WVCP100
VI-WVCM200
VI-WVCM140
VI-WVCM110
VI-WVCM100
VI-WVBP70
VI-WVBP110
VI-WVBP102
VI-WVBP100
VI-WVBM900
KEYART
VI-WVBM90
VI-WVBM80
VI-WVBM190
VI-WVBM170
VI-WVBM140
VI-WJ523
VI-WJ521
VI-WJ450
VI-WJ410
VI-WJSQ308
VI-WD7/MK
KEYART
VI-WD2N
VI-VTL-W
VI-VPT4023
VI-TVB125
VI-TC21S3M
VI-PTZFI/G
VI-PS 18M
VI-PAR/MON
VI-PAR/CAM
VI-MY-1CD
VI-MY-DS
KEYART
VI-MY-CA
VI-MO/BTM
VI-MJ-1ADA
VI-MJ-DS
VI-MA6024
VI-KXA11BS
VI-JC43BL
VI-JCM1000
VI-IR60071
VI-IR600BU
VI-IR-WIDE
KEYART
VID-WV95
VID-WV83
VID-WV80
VID-WV42
VID-WV40
VID-WVLF93
VID-WVLA6B
VID-WVLA4.
VID-WVLA36
VID-WVLA18
VID-WVLA12
KEYART
VID-WVBM90
VID-WVBM80
VID-WVBL90
VID-WVBB10
VI-DIVERS
VI-CAMERA
VI-AG6730
VI-AG6124B
VI-AG6040
TRV-TT1AS
TRV-TTE914
We can see that rows like VID- are between rows like VI- . It seems that order by doesn't take in charge the '-' Ok. But when i execute this statement :
select keyart from articles where keyart > 'VI-ZFI/GN' ;
-- VI-ZFI/GN is my bigger result in my first query
i got this result
KEYART
VID-WVBB10
VID-WVBL90
VID-WVBM80
VID-WVBM90
VID-WVLA12
VID-WVLA18
VID-WVLA36
VID-WVLA4.
VID-WVLA6B
VID-WVLF93
VID-WV40
KEYART
VID-WV42
VID-WV80
VID-WV83
VID-WV95
In this cas it seems that order by take in charge the '-'!!!
How can i do to have have no row in my second select or that the 2 queries order the row the same?
Please help me , it's quite urgent ....
thanks a lot
Fab
null

Hi,
With the data provided by you,i created the same set of table with the values.Tried the same query,when sorting it considers '-' also and then only it sorts.For me the order was perferct with 'VID' values first and then 'VI' values.
when i issued the second query the values of 'VID' alone came .
i think something has gone wrong when the data has been feed.maybe u have entered the data in the lowercase and some values in uppercase.
For me with the same set of values it is working perfectly.
null

Similar Messages

  • Prepared Statement with ORDER BY

    I am trying to use order by with prepared statement but it is not ordering.
    String sql = "SELECT * FROM MATERIAL WHERE (LOWER(NAMEE) LIKE ('%' || ? || '%') ORDER BY ? ";
    PreparedStatement ps=CM.getStatement(sql);
    ps.setString(1,p);
    ps.setString(2,sort);
              ResultSet r = ps.executeQuery();
    Can any one tell me how do I use prepared statement with order by

    You can not parameterize column names and such, only literals. You should build the ORDER BY clause dynamically.

  • Display the sql statement with arguments with ojdbc14_g.jar

    Hi,
    I'd like to display the sql statements with ojdbc14_g.jar.
    So I've followed the documentation and set an OracleLog.properties file which is linked to my java program.
    The problem is the trace generated is huge and I only need the SQL requests wich are made with the arguments but I don't know how to configure that.
    Have you got a sample file which handle that ?
    I've tried that :
    oracle.jdbc.handlers=java.util.logging.ConsoleHandler
    java.util.logging.ConsoleHandler.level=CONFIG
    java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
    oracle.level=INFO
    oracle.jdbc.driver.level=OFF
    oracle.jdbc.driver.OraclePreparedStatement.level=OFF
    oracle.jdbc.pool.level=OFF
    oracle.jdbc.util.level=OFF
    oracle.sql.level=INFO
    But that doesn't display only the SQL and args :(
    Regards.

    The fact is the statement are made by ejb entities on JBoss so I don't have a way to make specific logger to display the sql order. The only thing I can do is to set the log4j org.jboss.ejb.plugins.cmp to a trace level in order to see the sql order but without the arguments.
    I tried those traces however I see stuff like that without any SQL orders :
    <<
    10:10:53,833 INFO [STDOUT] NFO: PhysicalConnection.getRestrictGetTables() returned false
    29 nov. 2007 10:10:52 oracle.jdbc.driver.PhysicalConnection getRemarksReporting
    INFO: PhysicalConnection.getRemarksReporting()
    29 nov. 2007 10:10:52 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
    INFO: PhysicalConnection.getRestrictGetTables() returned false
    29 nov. 2007 10:10:52 oracle.jdbc.driver.PhysicalConnection getDefaultFixedString
    INFO: PhysicalConnection.getDefaultFixedString() returning false
    29 nov. 2007 10:10:52 oracle.jdbc.driver.OraclePreparedStatement setString
    INFO: OraclePreparedStatement.setString(paramIndex=1, x=%)
    29 nov. 2007 10:10:52 oracle.jdbc.driver.OraclePreparedStatement setString
    INFO: OraclePreparedStatement.setString(paramIndex=2, x=VIEW_ACTION_NAMES)
    29 nov. 2007 10:10:52 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
    INFO: PhysicalConnection.getRestrictGetTables() returned false
    29 nov. 2007 10:10:52 oracle.jdbc.driver.T4CPreparedStatement allocateTmpByteArray
    GRAVE: oracle.jdbc.driver.T4CPreparedStatement.allocateTmpByteArray : Re-allocate byte array of size : 4000
    29 nov. 2007 10:10:52 oracle.jdbc.driver.OracleResultSetImpl close
    INFO: OracleResultSetImpl.close()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getMetaData
    INFO: PhysicalConnection.getMetaData()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getCatalog
    INFO: PhysicalConnection.getCatalog()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRemarksReporting
    INFO: PhysicalConnection.getRemarksReporting()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
    INFO: PhysicalConnection.getRestrictGetTables() returned false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRemarksReporting
    INFO: PhysicalConnection.getRemarksReporting()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
    INFO: PhysicalConnection.getRestrictGetTables() returned false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getDefaultFixedString
    INFO: PhysicalConnection.getDefaultFixedString() returning false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.OraclePreparedStatement setString
    INFO: OraclePreparedStatement.setString(paramIndex=1, x=%)
    29 nov. 2007 10:10:53 oracle.jdbc.driver.OraclePreparedStatement setString
    INFO: OraclePreparedStatement.setString(paramIndex=2, x=PROCESS_TYPE_HIERARCHY)
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
    INFO: PhysicalConnection.getRestrictGetTables() returned false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.T4CPreparedStatement allocateTmpByteArray
    GRAVE: oracle.jdbc.driver.T4CPreparedStatement.allocateTmpByteArray : Re-allocate byte array of size : 4000
    29 nov. 2007 10:10:53 oracle.jdbc.driver.OracleResultSetImpl close
    INFO: OracleResultSetImpl.close()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getMetaData
    INFO: PhysicalConnection.getMetaData()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getMetaData
    INFO: PhysicalConnection.getMetaData()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getCatalog
    INFO: PhysicalConnection.getCatalog()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRemarksReporting
    INFO: PhysicalConnection.getRemarksReporting()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
    INFO: PhysicalConnection.getRestrictGetTables() returned false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRemarksReporting
    INFO: PhysicalConnection.getRemarksReporting()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
    INFO: PhysicalConnection.getRestrictGetTables() returned false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getDefaultFixedString
    INFO: PhysicalConnection.getDefaultFixedString() returning false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.OraclePreparedStatement setString
    INFO: OraclePreparedStatement.setString(paramIndex=1, x=%)
    29 nov. 2007 10:10:53 oracle.jdbc.driver.OraclePreparedStatement setString
    INFO: OraclePreparedStatement.setString(paramIndex=2, x=PROCESS_TYPE_HIERARCHY)
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
    INFO: PhysicalConnection.getRestrictGetTables() returned false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.T4CPreparedStatement allocateTmpByteArray
    GRAVE: oracle.jdbc.driver.T4CPreparedStatement.allocateTmpByteArray : Re-allocate byte array of size : 4000
    29 nov. 2007 10:10:53 oracle.jdbc.driver.OracleResultSetImpl close
    INFO: OracleResultSetImpl.close()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getMetaData
    INFO: PhysicalConnection.getMetaData()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getCatalog
    INFO: PhysicalConnection.getCatalog()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRemarksReporting
    INFO: PhysicalConnection.getRemarksReporting()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
    INFO: PhysicalConnection.getRestrictGetTables() returned false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRemarksReporting
    INFO: PhysicalConnection.getRemarksReporting()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
    INFO: PhysicalConnection.getRestrictGetTables() returned false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getDefaultFixedString
    INFO: PhysicalConnection.getDefaultFixedString() returning false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.OraclePreparedStatement setString
    INFO: OraclePreparedStatement.setString(paramIndex=1, x=%)
    29 nov. 2007 10:10:53 oracle.jdbc.driver.OraclePreparedStatement setString
    INFO: OraclePreparedStatement.setString(paramIndex=2, x=FORM_EMBEDDED_VIEWS)
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
    INFO: PhysicalConnection.getRestrictGetTables() returned false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.T4CPreparedStatement allocateTmpByteArray
    GRAVE: oracle.jdbc.driver.T4CPreparedStatement.allocateTmpByteArray : Re-allocate byte array of size : 4000
    29 nov. 2007 10:10:53 oracle.jdbc.driver.OracleResultSetImpl close
    INFO: OracleResultSetImpl.close()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getMetaData
    INFO: PhysicalConnection.getMetaData()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getMetaData
    INFO: PhysicalConnection.getMetaData()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getCatalog
    INFO: PhysicalConnection.getCatalog()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRemarksReporting
    INFO: PhysicalConnection.getRemarksReporting()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
    INFO: PhysicalConnection.getRestrictGetTables() returned false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRemarksReporting
    INFO: PhysicalConnection.getRemarksReporting()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
    INFO: PhysicalConnection.getRestrictGetTables() returned false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getDefaultFixedString
    INFO: PhysicalConnection.getDefaultFixedString() returning false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.OraclePreparedStatement setString
    INFO: OraclePreparedStatement.setString(paramIndex=1, x=%)
    29 nov. 2007 10:10:53 oracle.jdbc.driver.OraclePreparedStatement setString
    INFO: OraclePreparedStatement.setString(paramIndex=2, x=FORM_EMBEDDED_VIEWS)
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getRestrictGetTables
    INFO: PhysicalConnection.getRestrictGetTables() returned false
    29 nov. 2007 10:10:53 oracle.jdbc.driver.T4CPreparedStatement allocateTmpByteArray
    GRAVE: oracle.jdbc.driver.T4CPreparedStatement.allocateTmpByteArray : Re-allocate byte array of size : 4000
    29 nov. 2007 10:10:53 oracle.jdbc.driver.OracleResultSetImpl close
    INFO: OracleResultSetImpl.close()
    29 nov. 2007 10:10:53 oracle.jdbc.driver.PhysicalConnection getMetaData
    INFO: PhysicalConnection.getMetaData()
    29 nov. 20>>

  • SQL-Statement with OO4O

    Hello together,
    I post this Question here in
    Re: SQL-Statement with OO4O
    and i should paste my question again in an another database forum.
    now here again:
    I have here following Problem:
    Everthime I make a connection to my database with this code
    Set oSess = Server.CreateObject("OracleInProcServer.XOraSession")
    Set oDB = oSess.DbOpenDatabase(tnsname, user/PWD, 4)
    I get always this Statement in the DB-queue
    SELECT parameter, VALUE
    FROM SYS.nls_database_parameters
    WHERE parameter IN ('NLS_CHARACTERSET', 'NLS_NCHAR_CHARACTERSET')
    Can me anyone tell me why I get this statement and how I can disable it?
    Best Regards
    Andy

    Hi,
    What can you do/change?I must ask next week my boss when he is back,
    what kind of changes I can do.
    Can you add a PL/SQL call to DBMS_APPLICATION_INFO into application?my boss must give me the permission to do a call to DBMS_APPLICATION_INFO.
    A way to identify the source of the badly behaving code is required; whether that be within the DB or external of it.I think so too.
    So please wait, until I have talk with my boss, than I will give you the answer you want. Sorry.
    Any other ideas, what I can do without call/changes on the database to find the problem?
    Best Regards
    Andy

  • Problem with order by clause

    Hai all,
    I have problem with order by clause,
    My query is
    "select number from table1 order by number asc "
    and the output is displaying as
    1
    10
    12
    13
    15
    17
    19
    2
    20
    21
    22
    But if we give order by it should display as below only right ?
    1
    2
    10
    12
    13
    15
    17
    19
    20
    21
    22 ........
    Please help me why it is not displaying like it. and how to make the statement to display like the second case. Thanks in advance.
    Regards,
    Uraja

    The column datatype that you are selecting is not of NUMBER datatype(might be char or varchar2) hence you are getting such result set.
    And for this purpose, it is recommended to set datatype of a column appropriately.
    For now you can add TO_NUMBER function to column in ORDER BY clause, only if it has data of number type.
    Edited by: Ora on 19 Nov, 2012 3:10 AM

  • Pl/sql statement with output in reports

    Hello,
    I am quite new to reports and pl/sql, i have built a pl/sql statement with some loops that works fine when running it in sqlplus.
    I would really like to have this running in reports with the variables (v_year, v_month and v_sumvalue) in a table/record in the data view, so i can use them just like any ordinary fields in a table for example in a diagram.
    I have tried to create a package spec, setting up a record with the variables as fields. And then a pl/sql function with the following sql (which was a bit modified to work in the pl/sql function). Everything seemed to work since the pl/sql table/record was there with the variables as fields in it, but it never returned anything... just fatal error.
    Here is the original pl/sql statement which is working in sqlplus, any help/directions in how to get this working so i can use the variables like fileds in a regular table would be fantastic:
    DECLARE
       v_year number(4);
       v_month number(2);
       v_sumvalue number(9,3);
       v_sta varchar2(10);
       v_end varchar2(10);
       v_stopmonth number(2);
    BEGIN
       --## Get last 5 years ##--
       select
          to_char(add_months(sysdate,-60),'YYYY'),
          to_char(sysdate,'MM')
          into v_year, v_stopmonth
       from
          dual;
       --dbms_output.put_line(v_year);
       --## Loop 5 years ##--
       for i in 1..5 loop
          v_year := v_year + 1;
          --dbms_output.put_line(v_year);
          --## Loop 12 times (months) ##--
          for k in 0..11 loop
             v_month := k +1;
             --dbms_output.put_line(v_year ||'-'|| v_month);
             select
                sum(nvl(p.value,0)) / 3,
                last_day(add_months(to_date(v_year ||'-'|| v_month ||'-01','YYYY-MM-DD'),-3))+1,
                last_day(to_date(v_year ||'-'|| v_month ||'-01','YYYY-MM-DD'))
                into v_sumvalue, v_sta, v_end
             from
                project p
             where
                p.country_code = 'SWE'
             and
                p.project_type_code = 'P'
             and
                p.start_date between last_day(add_months(to_date(v_year ||'-'|| v_month ||'-01','YYYY-MM-DD'),-3))+1 and last_day(to_date(v_year ||'-'|| v_month ||'-01','YYYY-MM-DD'))
             and
                p.q_category_code between 1000 and 1299
             and
                p.geography_code between 2100 and 2199;
             dbms_output.put_line(v_year ||'-'|| v_month ||' '|| v_sumvalue);
             --dbms_output.put_line(v_year ||'-'|| v_month ||' '|| v_sumvalue ||' '|| v_sta ||' '|| v_end);
          --## Stop monthloop ##--
          end loop;
       --## Stop yearloop ##-
       end loop;
    END;Output:
    2003-1 19.1
    2003-2 20.1
    2007-11 164.5
    2007-12 135.167Best regards,
    Olle

    Hi,
    Maybe pipelined functions will be useful for you:
    http://www.oracle.com/technology/sample_code/tech/pl_sql/htdocs/x/Table_Functions_Cursor_Expressions/Pipelined_Table_Functions.htm
    Regards
    Jakub Flejmer

  • Dynamic SQL Statement with table name

    Dear all
    i like to have a SQL statement with a dynamic tablename. Is this possible? If yes, how?
    should be something like "select * from <mytablename>"
    Thank you
    Herbert

    Yes this is possible. use the below reference code for this.
    data: g_tablename type w_tabname,
            gv_dref TYPE REF TO data.
    FIELD-SYMBOLS: <g_itab> TYPE STANDARD TABLE.
    gv_tabname = p_tablename (take table name form selection screen or as per ur requirement)
    CREATE DATA gv_dref TYPE TABLE OF (g_tabname).
    ASSIGN gv_dref->* TO <g_itab>.
    now use the below select query to fetch the data
      SELECT * FROM (gv_tabname) INTO TABLE <g_itab>.
    Hope this will help

  • How to find sql statement with Unix process pid

    Hi
    how to find sql statement with Unix process pid
    is there any view to find that.
    please if so let me know
    Thanks in advance

    this is how I am doing this:
    oracle 7352340 7459066 0 07:47:10 - 0:00 oracleJDERED (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
    oracle 7459066 5386396 2 07:47:10 pts/1 0:01 sqlplus
    select sid,serial# from v$session where process='7459066';
    SID SERIAL#
    2178 6067
    select sql_text
    from
    v$sqlarea a,
    v$session b
    where a.hash_value = b.sql_hash_value
    and b.sid = 2178
    ;

  • SQL statement with union clause

    Hi,
    I have a scenario where i need to generate a sql statement with UNION .
    Eg:
    SELECT B.YY_ID,
    FROM XXXX.YY B
    WHERE (B.YY_TY= 'as')
    UNION
    SELECT B.YY_ID
    FROM XXXX.YY_ALT_NAME A, XXXX.YY B
    WHERE (A.YY_TY= 'zx'
    AND (B.YY_ID=A.YY_ID)"
    I tried ns1:table1() union ns3:table2() in XQuery.
    But it is pushdown as 2 seperate sqls.
    Is it possible to create XQuery that pushdown as SINGLE SQL statement with union clause ?
    Thanks

    No. See 3.1.1.5 in the document I referenced in your previous post.

  • ABAP/4 Open SQL statement with WHERE ... LIKE and pattern too long

    Dear All,
    I am getting an error "ABAP/4 Open SQL statement with WHERE ... LIKE and pattern too long" while executing the following statement:
    CLEAR LS_RANGE.
    LS_RANGE-SIGN     = 'I'
    +LS_RANGE-OPTION     = 'CP'     +
    LS_RANGE-LOW     = 'S_ADMI_FCD'
    LS_RANGE-HIGH     = 'S_ADMI_FCD'
    COLLECT LS_RANGE INTO LT_RANGE.
    SELECT *
               FROM UST12
               INTO CORRESPONDING FIELDS OF TABLE LT_OBJECT_VALUES
               WHERE FIELD IN LT_RANGE
               AND AKTPS   = 'A'.
    For options like BT(Between), EQ(Equal) in range table, this above query is executing without dump. But for option CP, it simply dumps & in dump what i found is, it is concatenating the value in low & high.
    Does anyone have any idea regarding open sql using range tables.
    Thanks,
    Bhupinder

    Hi,
    I commented as follows:
    If  LS_RANGE-HIGH is empty, you can use EQ, NE, GT, LE, LT,CP, and NP. These operators are the same as those that are used for logical expressions. Yet operators CP and NP do not have the full functional scope they have in normal logical expressions. They are only allowed if wildcards ( '*' or '+' ) are used in the input fields. If wildcards are entered on the selection screen, the system automatically uses the operator CP.
    If  LS_RANGE-HIGH  is filled, you can use BT (BeTween) and NB (Not Between). These operators correspond to BETWEEN and NOT BETWEEN that you use when you check if a field belongs to a range. You cannot use wildcard characters.
    You can try:
    CLEAR LS_RANGE.
    LS_RANGE-SIGN = 'I'.
    +LS_RANGE-OPTION = 'CP' +
    LS_RANGE-LOW = 'S_ADMI_FCD'.
    LS_RANGE-HIGH = 'S_ADMI_FCD'.
    FIND '*' IN LS_RANGE.
    IF sy-subrc = 0.
      LS_RANGE-OPTION = 'CP'.
    ELSE.
      LS_RANGE-OPTION = 'EQ'.
    ENDIF.
    COLLECT LS_RANGE INTO LT_RANGE.
    SELECT *
    FROM UST12
    INTO CORRESPONDING FIELDS OF TABLE LT_OBJECT_VALUES
    WHERE FIELD IN LT_RANGE
    AND AKTPS = 'A'.
    If you use wildcards the LS_RANGE  length should not exceed 10 characters.
    Hope this information is help to you.
    Regards,
    José

  • How to Run SQL Tuning Advisor on the SQL statement with SQL_ID?

    Can you give the steps to run the SQL tuning advisor on the SQL statement with SQL_ID?
    Database version: 10g Release 2

    Hi,
    You can use either the automatic SQL tuning features that are accessible from Enterprise Manager Database Console on the "Advisor Central" page or trough SQL*PLUS using the DBMS_SQLTUNE pakage:
    -- creating the tuning task
    set serveroutput on
    declare
      l_sql_tune_task_id  varchar2(100);
    begin
      l_sql_tune_task_id := dbms_sqltune.create_tuning_task (
                              sql_id      => '<your_sql_id>',
                              scope       => dbms_sqltune.scope_comprehensive,
                              time_limit  => 60,
                              task_name   => '<your_tuning_task_name>',
                              description => 'tuning task for statement your_sql_id.');
      dbms_output.put_line('l_sql_tune_task_id: ' || l_sql_tune_task_id);
    end;
    -- executing the tuning task
    exec dbms_sqltune.execute_tuning_task(task_name => '<your_tuning_task_name>');
    -- displaying the recommendations
    set long 100000;
    set longchunksize 1000
    set pagesize 10000
    set linesize 100
    select dbms_sqltune.report_tuning_task('<your_tuning_task_name>') as recommendations from dual;For more information, take a look at link provided by Jaffy.
    Cheers
    Legatti

  • Query with order by clause

    Hi,
    I found a query with order by clause in procedure which is taking long time.
    Stats are upto date.
    Total Rows :650000.
    It is ordered by primary key column.
    select * from table_name order by col1;
    col1 is a primary key.No of cpu's used is 4.
    can anyone suggest me a better solution to improve the performance of a query.
    Is it better to use parallel hint for above scenario.
    Any help really apprecaited.
    Thanks in advance.

    Hi,
    Thanks for ur immediate reply.
    It doesn't have where clause.
    below is the plan
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 619071987
    | Id  | Operation                   | Name                 | Rows  | Bytes | Cos
    |   0 | SELECT STATEMENT            |                      |   671K|   255M| 125
    |   1 |  TABLE ACCESS BY INDEX ROWID| FULL_ITEM_FACILITIES |   671K|   255M| 125
    |   2 |   INDEX FULL SCAN           | FIF_PK               |   671K|       |
    9 rows selected
    Executed in 0.094 secondsThanks in advance
    Edited by: unique on Jun 22, 2009 8:26 AM

  • Long run time with ORDER by clause

    Hi,
    I am having a query which is executing fine(in 2 mins) but when i am using order by clause in it, its taking around 13 mins.
    Can anyone suggest what could be th reason and how to execute the same query are get the ordered record?
    thanks.

    Sorry for not providing complet details.
    Database version id 10g.
    Below is the execution plan when using with order by clause.
    Execution Plan
    | Id  | Operation                              | Name              | Rows  | Bytes | Cost  |
    |   0 | SELECT STATEMENT                       |                   |     1 |   118 |  1538 |
    |   1 |  FILTER                                |                   |       |       |       |
    |   2 |   HASH JOIN                            |                   | 16657 |  1089K|    56 |
    |   3 |    TABLE ACCESS FULL                   | FILETYP           |     6 |    60 |     3 |
    |   4 |    TABLE ACCESS FULL                   | FILETYPSOURCEID   | 16657 |   927K|    52 |
    |   5 |   NESTED LOOPS                         |                   |     1 |    35 |     3 |
    |   6 |    TABLE ACCESS BY INDEX ROWID         | FILEWAREHOUSE     |     1 |    25 |     2 |
    |   7 |     INDEX RANGE SCAN                   | FILEWAREHOUSE_DX2 |     1 |       |     2 |
    |   8 |    TABLE ACCESS BY INDEX ROWID         | EXTFILE           |     1 |    10 |     1 |
    |   9 |     INDEX UNIQUE SCAN                  | PK_EXTFILE        |     1 |       |     1 |
    |  10 |  SORT ORDER BY                         |                   |     1 |   118 |  1538 |
    |  11 |   NESTED LOOPS                         |                   |     1 |   118 |  1534 |
    |  12 |    NESTED LOOPS OUTER                  |                   |     1 |   100 |  1533 |
    |  13 |     NESTED LOOPS OUTER                 |                   |     1 |    96 |  1532 |
    |  14 |      NESTED LOOPS                      |                   |     1 |    88 |  1531 |
    |  15 |       HASH JOIN                        |                   |     5 |   360 |  1524 |
    |  16 |        TABLE ACCESS BY INDEX ROWID     | RTXN              |     1 |    22 |     1 |
    |  17 |         NESTED LOOPS                   |                   |   117 |  5148 |  1518 |
    |  18 |          VIEW                          | VW_SQ_1           | 20869 |   448K|  1441 |
    |  19 |           HASH GROUP BY                |                   | 20869 |   427K|  1441 |
    |  20 |            FILTER                      |                   |       |       |       |
    |  21 |             TABLE ACCESS BY INDEX ROWID| RTXNSTATHIST      | 20869 |   427K|  1304 |
    |  22 |              INDEX RANGE SCAN          | RTXNSTATHIST_DX2  | 20869 |       |    29 |
    |  23 |          INDEX RANGE SCAN              | PK_RTXN           |     1 |       |     1 |
    |  24 |           NESTED LOOPS                 |                   |     1 |    24 |     3 |
    |  25 |            TABLE ACCESS BY INDEX ROWID | FILEWAREHOUSE     |     1 |    14 |     2 |
    |  26 |             INDEX RANGE SCAN           | FILEWAREHOUSE_DX2 |     1 |       |     2 |
    |  27 |            TABLE ACCESS BY INDEX ROWID | EXTFILE           |     1 |    10 |     1 |
    |  28 |             INDEX UNIQUE SCAN          | PK_EXTFILE        |     1 |       |     1 |
    |  29 |        TABLE ACCESS FULL               | RTXNTYP           |     1 |    28 |     5 |
    |  30 |       TABLE ACCESS BY INDEX ROWID      | RTXNSTATHIST      |     1 |    16 |     2 |
    |  31 |        INDEX RANGE SCAN                | PK_RTXNSTATHIST   |     1 |       |     1 |
    |  32 |      TABLE ACCESS BY INDEX ROWID       | NTWKNODE          |     1 |     8 |     1 |
    |  33 |       INDEX UNIQUE SCAN                | PK_NTWKNODE       |     1 |       |     1 |
    |  34 |     INDEX UNIQUE SCAN                  | PK_ORG            |     1 |     4 |     1 |
    |  35 |    TABLE ACCESS BY INDEX ROWID         | ACCT              |     1 |    18 |     1 |
    |  36 |     INDEX UNIQUE SCAN                  | PK_ACCT           |     1 |       |     1 |
    Below is the execution plan when running without ORDER BY clause...
    Execution Plan
    | Id  | Operation                             | Name              | Rows  | Bytes | Cost  |
    |   0 | SELECT STATEMENT                      |                   |     1 |   135 |  1537 |
    |   1 |  FILTER                               |                   |       |       |       |
    |   2 |   HASH JOIN                           |                   | 16657 |  1089K|    56 |
    |   3 |    TABLE ACCESS FULL                  | FILETYP           |     6 |    60 |     3 |
    |   4 |    TABLE ACCESS FULL                  | FILETYPSOURCEID   | 16657 |   927K|    52 |
    |   5 |   NESTED LOOPS                        |                   |     1 |    35 |     3 |
    |   6 |    TABLE ACCESS BY INDEX ROWID        | FILEWAREHOUSE     |     1 |    25 |     2 |
    |   7 |     INDEX RANGE SCAN                  | FILEWAREHOUSE_DX2 |     1 |       |     2 |
    |   8 |    TABLE ACCESS BY INDEX ROWID        | EXTFILE           |     1 |    10 |     1 |
    |   9 |     INDEX UNIQUE SCAN                 | PK_EXTFILE        |     1 |       |     1 |
    |  10 |  NESTED LOOPS                         |                   |     1 |   135 |  1534 |
    |  11 |   NESTED LOOPS OUTER                  |                   |     1 |   117 |  1533 |
    |  12 |    NESTED LOOPS OUTER                 |                   |     1 |   113 |  1532 |
    |  13 |     NESTED LOOPS                      |                   |     1 |   105 |  1531 |
    |  14 |      HASH JOIN                        |                   |     5 |   445 |  1524 |
    |  15 |       TABLE ACCESS FULL               | RTXNTYP           |     1 |    28 |     5 |
    |  16 |       TABLE ACCESS BY INDEX ROWID     | RTXN              |     1 |    22 |     1 |
    |  17 |        NESTED LOOPS                   |                   |   117 |  7137 |  1518 |
    |  18 |         VIEW                          | VW_SQ_1           | 20869 |   794K|  1441 |
    |  19 |          HASH GROUP BY                |                   | 20869 |   427K|  1441 |
    |  20 |           FILTER                      |                   |       |       |       |
    |  21 |            TABLE ACCESS BY INDEX ROWID| RTXNSTATHIST      | 20869 |   427K|  1304 |
    |  22 |             INDEX RANGE SCAN          | RTXNSTATHIST_DX2  | 20869 |       |    29 |
    |  23 |         INDEX RANGE SCAN              | PK_RTXN           |     1 |       |     1 |
    |  24 |          NESTED LOOPS                 |                   |     1 |    24 |     3 |
    |  25 |           TABLE ACCESS BY INDEX ROWID | FILEWAREHOUSE     |     1 |    14 |     2 |
    |  26 |            INDEX RANGE SCAN           | FILEWAREHOUSE_DX2 |     1 |       |     2 |
    |  27 |           TABLE ACCESS BY INDEX ROWID | EXTFILE           |     1 |    10 |     1 |
    |  28 |            INDEX UNIQUE SCAN          | PK_EXTFILE        |     1 |       |     1 |
    |  29 |      TABLE ACCESS BY INDEX ROWID      | RTXNSTATHIST      |     1 |    16 |     2 |
    |  30 |       INDEX RANGE SCAN                | PK_RTXNSTATHIST   |     1 |       |     1 |
    |  31 |     TABLE ACCESS BY INDEX ROWID       | NTWKNODE          |     1 |     8 |     1 |
    |  32 |      INDEX UNIQUE SCAN                | PK_NTWKNODE       |     1 |       |     1 |
    |  33 |    INDEX UNIQUE SCAN                  | PK_ORG            |     1 |     4 |     1 |
    |  34 |   TABLE ACCESS BY INDEX ROWID         | ACCT              |     1 |    18 |     1 |
    |  35 |    INDEX UNIQUE SCAN                  | PK_ACCT           |     1 |       |     1 |
    -------------------------------------------------------------------------------------------Edited by: user10754555 on Feb 5, 2010 6:02 PM

  • Case statement in order by clause

    Hi,
    I have written the below query which is having CASE statement in ORDER BY clause. Please let me know what mistake i have done in the query because am getting "Missing Keyword" Error.
    SELECT opn_quest_id, seq_nbr
    FROM opinion_question
    order by case when :p=1 then
    opn_quest_id,seq_nbr
    else
    opn_quest_id
    end;
    Thanks,
    Santhosh.S

    Try Ignore the following solution.
    SELECT   opn_quest_id, seq_nbr
    FROM   opinion_question
    ORDER BY   CASE
    WHEN : p = 1 THEN opn_quest_id || seq_nbr
    ELSE opn_quest_id
    END;
    What are the data type of the corresponding columns used in the CASE Statement? I have assumed it to be strings.
    !http://www.mysmiley.net/imgs/smile/sad/sad0049.gif! My Apologies....
    Regards,
    Jo
    Edited by: Joice John on Jul 13, 2009 3:07 AM
    Wrong Solution. Corrected by Sven.

  • Default where with order by clause

    Hi all
    How to use Default where with order by clause
    for example i want to use Default_where clause with order by clause
    Regards
    Shahzaib ismail

    Hi,
    I have a similar query for where clause.
    my query-find form is a multi record form like below:
    Criteria - Condition - Value
    Item/Category/Planner (List_Item) - Equals/Among (List_Item) - text_FIELD
    Item - Equals - ITEM_1
    Category - Among - ('CAT1', 'CAT2')
    Planner - Equals - PL1
    Find_BUTTON Clear_BUTTON
    User can select any criteria and condition combination and then enter the value in "Value" text field.
    My query is: how can I prepare a where clause based on user input since the user can enter any number of values/combinations? I guess I would have to use some looping to generate where clause.
    Thanks
    Imran

Maybe you are looking for

  • Can't take more than one picture through Messages

    I've had this problem since I first received my iPhone 6 and I always thought it just needed a software update, but I'm beginning to think that even that can't help. Basically when I try to choose the 'Take photo or video' option when sending a pictu

  • Having a hellish time with a RAID 5 Array

    Seems that after a hiccup and a freeze that required a hard restart things have been going downhill. Nothing but a gray screen after the restart and then had to start from an external drive. Raid utility showed 2 of the 3 drives in the raid set as ro

  • S415 Can't connect to wifi.

    I purchased an ideapad s415 and u530. the u530 and other devices including smartphones and xbox one can connect to the internet via wifi. The s415 however cannot. ive updated the driver and it hasnt worked. im on windows 8.1.

  • 6800gt, repeated short freezes, missing textures

    Picked up a 6800GT today. Used ATI's cleaner app to get rid of my old 9700pro drivers, and installed the 6800gt. Installed the newest 61.77 drivers. I ran Aquamark3, scored 58,536. Next I ran 3DMark. On the second test the screen started to freeze fo

  • Smartform Implementation issue for the report  RFKORD50

    Hi, I have a requirement to implement a smartform for FI Invoice.  This smartform should be configured in OB96 for the print program RFKORD50. Currently the SAP Script F140_DOCU_EXC_01 has been configured for Standard print program RFKORD50. This SAP