Problem with SImple Select Query

Hi
I am trying to write a simple Select SQL to a table and find out whether certain data exist or not. I have done this before but now for some reason this one is not working.
I started like this
select single * from ANLH where ANLN1 = rec-Asset
                                             and BUKRS = Comp_Cd.
* Error Handler for non-existent empno in the database
  if sy-subrc = 0 or rec-asset = ''.
     rec_failed = 'T'.
     concatenate 'Asset does not exist' rec-asset into asst_err.
  endif.
when i debugged the code i found out that sy-subrc  is returning 4 all the time. (i have passes some numbers in rec-Asset which i know doesn't exist in that table.
So i have modified the code to see if its pulling anything.
like this
select single ANLN1 into v_Asset from ANLH where ANLN1 = rec-Asset
                                             and BUKRS = Comp_Cd.
* Error Handler for non-existent empno in the database
  if sy-subrc = 0 or rec-asset = ''.
     rec_failed = 'T'.
     concatenate 'Asset does not exist' rec-asset into asst_err.
  endif.
in debug v_asset is always empty (for real number and for the madeup number)
Please help.
Thanks
Edited by: Anwarul Kabir on Apr 3, 2008 9:27 PM
Edited by: Anwarul Kabir on Apr 3, 2008 9:29 PM
Edited by: Anwarul Kabir on Apr 3, 2008 9:30 PM

Thanks for the answer. But i thought i was doing the same. Anyway I replaced my code with yours but result is the same. I also did this
select single
ANLN1 into v_Asset
from ANLH where
ANLN1 = '20000544'
and BUKRS = '3000'.
I did SE11 and entered the table name and i can see that data.
but on my code i get sy-subrc=4 and v_Asset is blank
again i tried with this madeup number which i know its not in the table
select single
ANLN1 into v_Asset
from ANLH where
ANLN1 = '2056555433544'
and BUKRS = '3000'.
Get sy-subrc=4 and v_Asset is blank...
Is there anything special about the Table?

Similar Messages

  • How can i use index in select query.. facing problem with the select query.

    Hi Friends,
    I am facing a serious problem in one of the select query. It is taking a lot of time to fetch data in Production Scenario.
    Here is the query:
      SELECT * APPENDING CORRESPONDING FIELDS OF TABLE tbl_summary
        FROM ztftelat LEFT JOIN ztfzberep
         ON  ztfzberep~gjahr = st_input-gjahr
         AND ztfzberep~poper = st_input-poper
         AND ztfzberepcntr  = ztftelatrprctr
        WHERE rldnr  = c_telstra_accounting
          AND rrcty  = c_actual
          AND rvers  = c_ver_001
          AND rbukrs = st_input-bukrs
          AND racct  = st_input-saknr
          AND ryear  = st_input-gjahr
          And rzzlstar in r_lstar                            
          AND rpmax  = c_max_period.
    There are 5 indices present for Table ZTFTELAT.
    Indices of ZTFTELAT:
      Name   Description                                               
      0        Primary key( RCLNT,RLDNR,RRCTY,RVERS,RYEAR,ROBJNR,SOBJNR,RTCUR,RUNIT,DRCRK,RPMAX)                                          
      005    Profit (RCLNT,RPRCTR)
      1        Ledger, company code, account (RLDNR,RBUKRS, RACCT)                                
      2        Ledger, company code, cost center (RLDNR, RBUKRS,RCNTR)                           
      3        Account, cost center (RACCT,RCNTR)                                        
      4        RCLNT/RLDNR/RRCTY/RVERS/RYEAR/RZZAUFNR                        
      Z01    Activity Type, Account (RZZLSTAR,RACCT)                                        
      Z02    RYEAR-RBUKRS- RZZZBER-RLDNR       
    Can anyone help me out why it is taking so much time and how we can reduce it ? and also tell me if I want to use index number 1 then how can I use?
    Thanks in advance.

    Hi Shiva,
    I am using two more select queries with the same manner ....
    here are the other two select query :
    ***************1************************
    SELECT * APPENDING CORRESPONDING FIELDS OF TABLE tbl_summary
        FROM ztftelpt LEFT JOIN ztfzberep
         ON  ztfzberep~gjahr = st_input-gjahr
         AND ztfzberep~poper = st_input-poper
         AND ztfzberepcntr  = ztftelptrprctr
        WHERE rldnr  = c_telstra_projects
          AND rrcty  = c_actual
          AND rvers  = c_ver_001
          AND rbukrs = st_input-bukrs
          AND racct  = st_input-saknr
          AND ryear  = st_input-gjahr
          and rzzlstar in r_lstar             
          AND rpmax  = c_max_period.
    and the second one is
    *************************2************************
      SELECT * APPENDING CORRESPONDING FIELDS OF TABLE tbl_summary
        FROM ztftelnt LEFT JOIN ztfzberep
         ON  ztfzberep~gjahr = st_input-gjahr
         AND ztfzberep~poper = st_input-poper
         AND ztfzberepcntr  = ztftelntrprctr
        WHERE rldnr  = c_telstra_networks
          AND rrcty  = c_actual
          AND rvers  = c_ver_001
          AND rbukrs = st_input-bukrs
          AND racct  = st_input-saknr
          AND ryear  = st_input-gjahr
          and rzzlstar in r_lstar                              
          AND rpmax  = c_max_period.
    for both the above table program is taking very less time .... although both the table used in above queries have similar amount of data. And i can not remove the APPENDING CORRESPONDING. because i have to append the data after fetching from the tables.  if i will not use it will delete all the data fetched earlier.
    Thanks on advanced......
    Sourabh

  • How to reduce functions with simple select query?

    I have a function to identify the root parent of a particular id. I use this in function in select query,which invokes function for every row in table.I need to merge the function inside the query itself.Please suggest  me.
    Function
    CREATE OR REPLACE FUNCTION fnroot(v_id int ) return int as
    v_left int;
    v_right int;
    v-result int;
    begin
    select left,right into v_left,v_right from sam where id=v_id;
    select id into v_result from sam
    where id in (select id from mst m where m.depth=2 )
    and left < v_left and right > v_right;
    return v_result;
    end
    query:
    select fnroot(s.id) from master s;

    Hi,
    Ramin's idea is very good. You must use joins in function as below
    CREATE OR REPLACE FUNCTION fnroot(v_id int ) return int as
        v_result int;
    Begin
    select  s.id into v_result
      from sam s on s.id = v_id
               left join sam s2 on (s2.id in (select id from mst m where m.depth = 2) and s2.left < s.left and s2.right > s.right)
    return v_result;
    End;
    Regards
    Mahir M. Quluzade

  • Performance issue after Upgrade from 4.7 to ECC 6.0 with a select query

    Hi All,
    There is a Performance issue after Upgrade from 4.7 to ECC 6.0 with a select query in a report painter.
    This query is working fine when executed in 4.7 system where as it is running for more time in ECC6.0.
    Select query is on the table COSP.
    SELECT (FIELD_LIST)
            INTO CORRESPONDING FIELDS OF TABLE I_COSP PACKAGE SIZE 1000
            FROM  COSP CLIENT SPECIFIED
            WHERE GJAHR IN SELR_GJAHR
              AND KSTAR IN SELR_KSTAR
              AND LEDNR EQ '00'
              AND OBJNR IN SELR_OBJNR
              AND PERBL IN SELR_PERBL
              AND VERSN IN SELR_VERSN
              AND WRTTP IN SELR_WRTTP
              AND MANDT IN MANDTTAB
            GROUP BY (GROUP_LIST).
       LOOP AT I_COSP      .
         COSP                           = I_COSP      .
         PERFORM PCOSP       USING I_COSP-_COUNTER.
         CLEAR: $RWTAB, COSP                          .
         CLEAR CCR1S                         .
       ENDLOOP.
    ENDSELECT.
    I have checked with the table indexes, they were same as in 4.7 system.
    What can be the reson for the difference in execution time. How can this be reduced without adjusting the select query.
    Thanks in advance for the responses.
    Regards,
    Dedeepya.

    Hi,
    ohhhhh....... lots of problems in select query......this is not the way you should write it.
    Some generic comments:
    1. never use SELECT
                       endselect.
       SELECT
      into table
       for all entries in table
      where.
       use perform statment after this selection.
    2. Do not use into corresponding fields. use exact structure type.
    3. use proper sequence of fields in the where condition so that it helps table go according to indexes.
        e.g in your case
              sequence should be
    LEDNR
    OBJNR
    GJAHR
    WRTTP
    VERSN
    KSTAR
    HRKFT
    VRGNG
    VBUND
    PARGB
    BEKNZ
    TWAER
    PERBL
    sequence should be same as defined in table.
    Always keep select query as simple as possible and perform all other calculations etc. afterwords.
    I hope it helps.
    Regards,
    Pranaya

  • Problem in my Select query

    Hi Experts,
    I need a clarification in my Select query.
    Have created a custom search help and my requirement is I have Request ID, Last and First Name as my search parameters. I need to fetch the values from my Ztable on search with the above said search parameters, where its workflow status = 30.
       * Get Request ID
      lv_pattern = <ls_query_params>-request_id.
      IF lv_pattern CA '*'.
        REPLACE ALL OCCURRENCES OF '*' IN lv_pattern WITH '%'.
      ENDIF. " IF lv_pattern CA '*'
      IF lv_pattern IS INITIAL.
        lv_pattern = '%'.
      ENDIF. " IF lv_pattern IS INITIAL
    ** Get NACHN - Lastname
        lv_last_name = <ls_query_params>-nachn.
        IF lv_last_name CA '*'.
          REPLACE ALL OCCURRENCES OF '*' IN lv_last_name WITH '%'.
        ENDIF. " IF lv_pattern CA '*'
        IF lv_last_name IS INITIAL.
          lv_last_name = '%'.
        ENDIF. " IF lv_pattern IS INITIAL
    ** Get VORNA - First Name
        lv_first_name = <ls_query_params>-vorna.
        IF lv_first_name CA '*'.
          REPLACE ALL OCCURRENCES OF '*' IN lv_first_name WITH '%'.
        ENDIF. " IF lv_pattern CA '*'
        IF lv_first_name IS INITIAL.
          lv_first_name = '%'.
        ENDIF. " IF lv_pattern IS INITIAL
    *Selecting the RequestID/Last and First Name values with workflow status as 30.
    SELECT zzreq_id " Internal number for appropriation request
                nachn
               vorna
      INTO TABLE lt_select_list
      FROM ZTABLE
      WHERE (  ( zzreq_id LIKE lv_pattern ) and
                     ( nachn like lv_last_name ) or
                      ( vorna LIKE lv_first_name ) )
           AND zzstatus = lv_workflow_status.
    My problem is, ofcourse this query is selecting all the records where status = 30 and even it works correctly, If I searches with Request ID(* or *3*).
    But am not able to select the records, if I searches with Last or First Name. Guess I did some thing wrong in select query.
    Please advice me.
    With Regards,
    Ram.

    Re: Problem in my Select query
    Krishna kumar Jun 9, 2014 7:52 AM (in response to Ramakrishnan Murugan)
    Hi Ramakrishnan,
                         Can you just try the below Select Query,
    SELECT zzreq_id
                nachn
               vorna
      INTO TABLE lt_select_list
      FROM ZTABLE
      WHERE ( zzreq_id     LIKE    lv_pattern                and
                         nachn         LIKE    lv_last_name         and
                         vorna          LIKE     lv_first_name )    and
                          zzstatus = lv_workflow_status.
    Cheers,
    Krishnakumar B.
    I think the above suggested query is same as your solution.

  • What is the wrong with my select query

    HI All,
    TYPES: BEGIN OF t_equi,
             equnr          TYPE equi-equnr,
             aedat          TYPE equi-aedat,
             matnr          TYPE equi-matnr,
             sernr          TYPE equi-sernr,
             kunde          TYPE equi-kunde,
             zzreg_date     TYPE equi-zzreg_date,
             zzin_indic     TYPE equi-zzin_indic,
             zzinvoice_num  TYPE equi-zzinvoice_num,
             zzinvoice_date TYPE equi-zzinvoice_date,
             kund1          TYPE equz-kund1,
          END OF t_equi,
    DATA: it_equi        TYPE TABLE OF t_equi,
      SELECT equnr
             aedat
             matnr
             sernr
             kunde          "Ship to
             zzreg_date
             zzin_indic
             zzinvoice_num
             zzinvoice_date
             kund1            "Sold to
             INTO TABLE it_equi
             FROM equi AS a
             INNER JOIN equz AS b
             ON a~equnr = b~equnr
             WHERE a~equnr      IN s_equnr AND
    *               aedat GE gv_rdate AND
                   a~matnr      IN s_matnr AND
                   a~sernr      IN s_sernr AND
                   a~kunde      IN r_shpbr_kunde AND
                   a~zzin_indic IN s_indic  AND
                   b~datbi      EQ c_datbi  AND 
                   b~kund1     IN r_sldbr_kund1 .
    what is the wrong with this select query.. ?
    its giving me error  "The column name "EQUNR" is unclear ."
    Thanks

    Hi ,
    write  tablename or alias in select also
    SELECT a~equnr and check.
    Regards

  • Problem in standard select query in fagll03

    Good Morning frndz,
    I m facing a problem while runnin fagll03. when executed it gives timeout error.
    When I debug it  , it gets stuck in a select query
    SELECT SINGLE * FROM t800m INTO CORRESPONDING FIELDS OF ls_b
    WHERE totable = ls_t800a-ntable
    AND fromtable = 'ACCIT_GLX'
    AND tofield = id_glflex_fieldname
    AND seqnr = space.
    The content in variable ls_t800a-ntable was FAGLFLEXA  and in id_glflex_fieldname was USNAM.
    When I cheked in table t800m, the entry could not be found. But in the report instead of setting
    sy-subrc = 0 , it is stuck in the select query itself....kindly suggest y it is happening so
    Regards,
    Vincy

    Re: Problem in my Select query
    Krishna kumar Jun 9, 2014 7:52 AM (in response to Ramakrishnan Murugan)
    Hi Ramakrishnan,
                         Can you just try the below Select Query,
    SELECT zzreq_id
                nachn
               vorna
      INTO TABLE lt_select_list
      FROM ZTABLE
      WHERE ( zzreq_id     LIKE    lv_pattern                and
                         nachn         LIKE    lv_last_name         and
                         vorna          LIKE     lv_first_name )    and
                          zzstatus = lv_workflow_status.
    Cheers,
    Krishnakumar B.
    I think the above suggested query is same as your solution.

  • Problems with Input Ready Query

    Hello All,
    I'm facing problems with input ready query for BI IP.
    I've created the input query on aggregation level and maintianed all the planning settings.  It is not allowing me to edit, when i'm attaching in the web template.
    I also attached a button copy function, and i'm able to execute it and save it, but it not allowing me to change manually.
    I also enabled the 3rd option for keyfigures...data can be changed with planning functions and user input.
    Please help me in this regard.
    We have just started the development of BI-IP, please suggest me if there are any notes to be applied.
    Regards
    Kumar

    Hello Johannes,
    Yes I've set to the finest granularity...even if it is Only one characteristic and one key figure without any restrictions...
    I've checked even planning tab page under properties...it is also fine..
    But still it is not allaowing me to go to edit mode...this is a fresh instalation and the query i'm working is the first one...
    Please suggest me if there are any notes to be applied, we are on Support Pack 10.
    Regards
    Jeevan Kumar

  • Need some help with the Select query.

    Need some help with the Select query.
    I had created a Z table with the following fields :
    ZADS :
    MANDT
    VKORG
    ABGRU.
    I had written a select query as below :
    select single vkorg abgru from ZADS into it_rej.
    IT_REJ is a Work area:
    DATA : BEGIN OF IT_REJ,
            VKORG TYPE VBAK-VKORG,
            ABGRU TYPE VBAP-ABGRU,
           END OF IT_REJ.
    This is causing performance issue. They are asking me to include the where condition for this select query.
    What should be my select query here?
    Please suggest....
    Any suggestion will be apprecaiated!
    Regards,
    Developer

    Hello Everybody!
    Thank you for all your response!
    I had changes this work area into Internal table and changed the select query. PLease let me know if this causes any performance issues?
    I had created a Z table with the following fields :
    ZADS :
    MANDT
    VKORG
    ABGRU.
    I had written a select query as below :
    I had removed the select single and insted of using the Structure it_rej, I had changed it into Internal table 
    select vkorg abgru from ZADS into it_rej.
    Earlier :
    IT_REJ is a Work area:
    DATA : BEGIN OF IT_REJ,
    VKORG TYPE VBAK-VKORG,
    ABGRU TYPE VBAP-ABGRU,
    END OF IT_REJ.
    Now :
    DATA : BEGIN OF IT_REJ occurs 0,
    VKORG TYPE VBAK-VKORG,
    ABGRU TYPE VBAP-ABGRU,
    END OF IT_REJ.
    I guess this will fix the issue correct?
    PLease suggest!
    Regards,
    Developer.

  • A simple select query taking forever

    Hi All
    I am not able to execute a simple select query, I traced my session and here is TKPROF of that Trace.
    Solaris 8 , Oracle 10.2.0.4.0
    TKPROF: Release 10.2.0.4.0 -
    Copyright (c) 1982, 2007, Oracle.  All rights reserved.
    Trace file: 502_ora_28260.trc
    Sort options: default
    count    = number of times OCI procedure was executed
    cpu      = cpu time in seconds executing
    elapsed  = elapsed time in seconds executing
    disk     = number of physical reads of buffers from disk
    query    = number of buffers gotten for consistent read
    current  = number of buffers gotten in current mode (usually for update)
    rows     = number of rows processed by the fetch or execute call
    select OBJECT_ID , ORACLE_USERNAME , SESSION_ID
    from
      v$locked_object
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        1      0.03      32.86          0          0          6           0
    total        3      0.03      32.86          0          0          6           0
    Misses in library cache during parse: 1
    Optimizer mode: CHOOSE
    Parsing user id: SYS
    Rows     Row Source Operation
          0  MERGE JOIN  (cr=0 pr=0 pw=0 time=60 us)
          0   SORT JOIN (cr=0 pr=0 pw=0 time=58 us)
          0    MERGE JOIN  (cr=0 pr=0 pw=0 time=42 us)
          1     SORT JOIN (cr=0 pr=0 pw=0 time=2443 us)
       1105      FIXED TABLE FULL X$KSUSE (cr=0 pr=0 pw=0 time=1204 us)
          0     SORT JOIN (cr=0 pr=0 pw=0 time=41 us)
       1001      FIXED TABLE FULL X$KTCXB (cr=0 pr=0 pw=0 time=16132 us)
          0   SORT JOIN (cr=0 pr=0 pw=0 time=0 us)
          0    FIXED TABLE FULL X$KTADM (cr=0 pr=0 pw=0 time=0 us)
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      SQL*Net message to client                       1        0.00          0.00
      buffer busy waits                              34        0.97         32.83
      SQL*Net break/reset to client                   1        0.00          0.00
    OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        1      0.03      32.86          0          0          6           0
    total        3      0.03      32.86          0          0          6           0
    Misses in library cache during parse: 1
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      SQL*Net message to client                       2        0.00          0.00
      SQL*Net message from client                     1       19.00         19.00
      buffer busy waits                              34        0.97         32.83
      SQL*Net break/reset to client                   1        0.00          0.00
    OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        0      0.00       0.00          0          0          0           0
    Execute      0      0.00       0.00          0          0          0           0
    Fetch        0      0.00       0.00          0          0          0           0
    total        0      0.00       0.00          0          0          0           0
    Misses in library cache during parse: 0
        1  user  SQL statements in session.
        0  internal SQL statements in session.
        1  SQL statements in session.
    Trace file: 502_ora_28260.trc
    Trace file compatibility: 10.01.00
    Sort options: default
           0  session in tracefile.
           1  user  SQL statements in trace file.
           0  internal SQL statements in trace file.
           1  SQL statements in trace file.
           1  unique SQL statements in trace file.
          64  lines in trace file.
          32  elapsed seconds in trace file. There is nothing fishy in alert logs... Please guide
    Thanks

    There it is TOP
    $ RUMPSHAKER>top
    load averages:  6.63,  7.45,  7.88;                    up 33+12:02:33           
    3631 processes: 3616 sleeping, 5 zombie, 1 stopped, 9 on cpu
    CPU states: 58.6% idle, 18.2% user, 23.2% kernel,  0.0% iowait,  0.0% swap
    Memory: 192G phys mem, 92G free mem, 96G swap, 96G free swap
       PID USERNAME LWP PRI NICE  SIZE   RES STATE    TIME    CPU COMMAND
    13752 ora0005    1  19    0 4243M 4219M sleep    5:21 62.78% oracle
    17758 ora0005    1  25    0 1174M 1156M cpu      1:05 37.12% oracle
    17923 root       1  57    0   18M   14M sleep  689:07 13.59% ecap_monitor
    20777 root      12  58    0   14M   13M sleep  864:33 11.55% OracleAgent
    18884 ora0004    1   1    0  830M  813M sleep    0:01  9.54% oracle
    12070 ora0004   61  58    0  320M  315M sleep   28.5H  8.29% emagent
    20347 root      16  59    0   33M   25M sleep   26.0H  6.34% caiUxsA2
    17949 ist0005    1  53    0 7984K 4984K cpu      0:00  3.93% top
         1 root       1  59    0 2912K 1288K sleep   32.2H  3.75% init
    15035 ora0001    1  46    0   32M   22M sleep  166:43  2.98% tnslsnr
      5748 ora0004   11  54    0  516M  496M sleep  389:37  2.78% oracle
    20567 ora0004    1  55    0   27M   22M sleep    0:00  2.69% sqlplus
      6730 ora0001    1  33    0  632M  616M sleep    0:06  2.67% oracle
    20557 ora0004    1  56    0   27M   23M sleep    0:00  2.53% sqlplus
      5355 ora0005    1  59    0 1154M 1137M sleep    0:04  2.46% oracleand VMSTAT 2 5
    $ RUMPSHAKER> vmstat 2 5
    kthr      memory            page            disk          faults      cpu
    r b w   swap  free  re  mf pi po fr de sr s0 s1 s2 sd   in   sy   cs us sy id
    6 8 0 143125576 74272080 4628 24012 488 150 149 0 0 4 4 -2 0 25037 192698 65249 38 26 36
    1 3 0 162803992 95246464 1989 6989 0 4 4 0 0 6 6 0  0 9170 57822 26434 8 13 79
    1 7 0 162801352 95240296 3043 15633 4 9737 9682 0 0 0 0 0 0 11277 73516 38200 16 16 68
    3 10 0 162801560 95227920 3326 12729 16 16862 16774 0 0 1 1 0 0 11377 86054 44758 16 17 68
    1 10 0 162784520 95186488 9638 48359 24 11682 11626 0 0 13 13 0 0 13484 149366 44205 23 29 47

  • Problem with simple query

    I have a problem with Oracle 10.2.0.5.0 and 11.2.0.1.0. Query result is wrong.
    SELECT t.id
      FROM (SELECT t.ID, MAX(t.nom) AS nom
              FROM (SELECT 2 AS ID, 200 AS nom
                      FROM dual
                    UNION ALL
                    SELECT 3 AS ID, 0 AS nom FROM dual) t
              LEFT JOIN (SELECT 0 AS ID_1, 0 AS nom_1 FROM dual) s
                ON s.id_1 = t.ID
             WHERE t.ID IN (2, 3)
             GROUP BY t.ID
            HAVING MAX(t.nom) != 0) t;Return nothing.
    But on Oracle 10.2.0.4.0 result is correct:
    ID  NOM
    2  200

    Looks like a bug related to ANSI joins.
    Check Oracle Support, maybe it's fixed in 11.2.0.2.
    It works with Oracle join syntax :
    Connected to Oracle Database 11g Enterprise Edition Release 11.2.0.1.0
    Connected as dev
    SQL>
    SQL> SELECT t.id
      2    FROM (SELECT t.ID, MAX(t.nom) AS nom
      3            FROM (SELECT 2 AS ID, 200 AS nom
      4                    FROM dual
      5                  UNION ALL
      6                  SELECT 3 AS ID, 0 AS nom FROM dual) t
      7                ,(SELECT 0 AS ID_1, 0 AS nom_1 FROM dual) s
      8           WHERE t.ID IN (2, 3)
      9           AND s.id_1(+) = t.ID
    10           GROUP BY t.ID
    11          HAVING MAX(t.nom) != 0) t;
            ID
             2

  • Simple Select query with 'where', 'and', 'between' clauses takes time

    Hi,
    I have a select query as below
    SELECT * FROM (SELECT a.*,ROWNUM currentStartRecord From (select ai_inbound.ai_inb_seq tableseq,'AI_INBOUND' tablename,'INBOUND' direction,ai_inbound.appl,ai_inbound.ai_date datetime,ai_inbound.ic_receiver_id pg_id,ai_inbound.ic_sender_id tp_id,ai_inbound.session_no,ai_inbound.ic_ctl_no,ai_inbound.msg_set_id msg_type,ai_inbound.appl_msg_ctl_no reference_no,ai_inbound.fg_version version,ai_inbound.msg_status status,ai_inbound.input_file_name,ai_inbound.output_file_name,ai_inbound.ack_file_name from ai_inbound where ai_inbound.appl = ? and ai_inbound.ai_date between ? and ? )a where ROWNUM <= 49)where currentStartRecord >= 0
    The above query takes longer time through application than expected when the date fields are passed whereas it works fine when no date fields are passed. We are using oracle9.2 version of the database. All the indexed columns and partitioned indexed columns are rebuild.
    Kindly let me know how can i tune up the query to improve the performance.
    Thanks

    Hi,
    I have a select query as below
    SELECT * FROM (SELECT a.*,ROWNUM currentStartRecord From (select ai_inbound.ai_inb_seq tableseq,'AI_INBOUND' tablename,'INBOUND' direction,ai_inbound.appl,ai_inbound.ai_date datetime,ai_inbound.ic_receiver_id pg_id,ai_inbound.ic_sender_id tp_id,ai_inbound.session_no,ai_inbound.ic_ctl_no,ai_inbound.msg_set_id msg_type,ai_inbound.appl_msg_ctl_no reference_no,ai_inbound.fg_version version,ai_inbound.msg_status status,ai_inbound.input_file_name,ai_inbound.output_file_name,ai_inbound.ack_file_name from ai_inbound where ai_inbound.appl = ? and ai_inbound.ai_date between ? and ? )a where ROWNUM <= 49)where currentStartRecord >= 0
    The above query takes longer time through application than expected when the date fields are passed whereas it works fine when no date fields are passed. We are using oracle9.2 version of the database. All the indexed columns and partitioned indexed columns are rebuild.
    Kindly let me know how can i tune up the query to improve the performance.
    Thanks

  • Big problem with a select using remote database

    Hi Guy.
    I have a big problem with a simple query, but this is a scenario.
    Actuallly I'm in Alexandria - Egypt with a server with Oracle 10.2.0.4 database 32 bit on linux Red Hat as 4.8. the server can connect to another database oracle but 9.2.0.6 installed on Red Hat As 4.5 placed in Milano Italy . Ttwo networks are connected via two adsl cisco router with firewall and Vpn functions. In Egypt there isn't a very good adsl.
    In Alexandria, I'm trying to connect to database in Italy with sqlplus. The sqlplus connected I write.. select * from addetti and all work fine.
    My problem is that when I try to make the same select on a table with many columns oracle database kill me a session.
    My table (ic_lav) is long 174 colums 1924 byte for row. Well when I write a query with select * from ic_lav all oracle close my session.
    So I began to change my query I start to
    select field1 from ic_lav... and work
    select field1,field2,field3,..........field50 from ic_lav and work
    select field1,field2,field3,..........field70 from ic_lav and doesn't work
    the select work with 68 columns
    problem: the query with more then 1064 byte for row doesn't work.
    I've tryed with anoter big table with the same problem, but the select fwork with 65 columns...
    Iit is obvious that there is any problem with the limit of the query.
    The same query (select * from ic_lav) in localMilano)l work fine.
    The same query (select * from ic_lav) in vpn with a better adsl line and openvpn software (NO CISCO firewall) WORK FINE.
    The same query connectetd in Milano with a vpn make with analogic modem and remote access by windows work fine.
    the query (make on my laptop connectet with vpn by cisco doesn't work.
    In cisco firewall we haven't any error (cisco man tell me so)
    on database 9 I found :
    *** 2009-06-12 09:49:45.509
    *** SESSION ID:(66.44406) 2009-06-12 09:49:45.497
    FATAL ERROR IN TWO-TASK SERVER: error = 12152
    *** 2009-06-12 09:49:45.509
    ksedmp: internal or fatal error
    Current SQL statement for this session:
    select * from ic_lis where ditta
    ----- Call Stack Trace -----
    but I don't understand why the lost connection problem (bug 3816595 A processstate dump is produced for a lost connection (12152) ) is caused by len of row
    Anybody have some idea ?
    Thank you

    My table (ic_lav) is long 174 colums 1924 byte for row. Well when I write a query with select * from ic_lav all oracle close my session.Do you get any error?
    If the query length is a problem, you could create a view and query the view instead to see if this problem is resolved.

  • Problem with timestamp in query

    I have problem with timestamp in JPA query.
    I wonna select all data from database where difference between two timestamps is more than 3 month.
    Database:
    ID timestamp1 timestamp2
    1 20008-11-19 15:02000 20008-08-19 15:02000
    2 20008-11-19 15:02000 20008-11-14 15:02000
    @Column(name = "timestamp1", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    public Date timestamp1;
    @Column(name = "timestamp2", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    public Date timestamp2;
    sql query works:
    select id from table where
    MONTH( DATE(timestamp1) - DATE(timestamp2) ) > 3
    but how I can write in Java?
    I't doesnt wrk:
    Query query = em.createQuery("SELECT f.id FROM Foo f WHERE MONTH( DATE(f.timestamp1) - DATE(f.timestamp2) ) > 3 ")
    error:
    ExceptionUtil E CNTR0020E: EJB threw an unexpected (non-declared) exception during invocation of method .
    Exception data: <openjpa-1.0.2-r420667:627158 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: An error occurred while parsing the query filter 'SELECT f.id FROM Foo f WHERE MONTH( DATE(f.timestamp1) - DATE(f.timestamp2) ) > 3'.
    Error message: <openjpa-1.0.2-r420667:627158 nonfatal user error> org.apache.openjpa.kernel.jpql.ParseException: Encountered "MONTH (" at character 438, but expected: ["(", "+", "-", ".", ":", "", "=", "?", "ABS", "ALL", "AND", "ANY", "AS", "ASC", "AVG", "BETWEEN", "BOTH", "BY", "CONCAT", "COUNT", "CURRENT_DATE", "CURRENT_TIME", "CURRENT_TIMESTAMP", "DELETE", "DESC", "DISTINCT", "EMPTY", "ESCAPE", "EXISTS", "FETCH", "FROM", "GROUP", "HAVING", "IN", "INNER", "IS", "JOIN", "LEADING", "LEFT", "LENGTH", "LIKE", "LOCATE", "LOWER", "MAX", "MEMBER", "MIN", "MOD", "NEW", "NOT", "NULL", "OBJECT", "OF", "OR", "ORDER", "OUTER", "SELECT", "SET", "SIZE", "SOME", "SQRT", "SUBSTRING", "SUM", "TRAILING", "TRIM", "UPDATE", "UPPER", "WHERE", <BOOLEAN_LITERAL>, <DECIMAL_LITERAL>, <IDENTIFIER>, <INTEGER_LITERAL>, <STRING_LITERAL>].
    at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder$ParsedJPQL.parse(JPQLExpressionBuilder.java:1665)
    at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder$ParsedJPQL.<init>(JPQLExpressionBuilder.java:1645)

    The error is indocating improper formatting of your JPQL string. MONTH is not understood. I would recommend using your SQL string in a createNativeQuery(...) call instead.
    Doug

  • Problem with unit in Query

    Hallo Experts,
    We encounter a problem with unit in our Query.
    Szenario:
    We use the Unit like PC, SET in Query.
    In Table T006 those Units have value 0 in the field ANDEC, so they will be rounded up and rounded down in Query.
    Our Problem is some Queries need the rounding up and down but others don't need this function.
    Where and how should we change to solve the problem.
    thanks & Best regards

    hi,
    if you want to control the rounding off while unit conversion you can do it from SPRO
    In the BW system, goto SPRO -> SAP NetWeaver -> General Settings -> Check Units of Measurement -> Units of Measurement -> Choose the unit corresponding to 'KM' -> Click on 'Details' button in the toolbar.
    Look the field 'Decimal Pl rounding'. Change this to 3 or whatever value you choose and see if it works.
    in above link i have taken example of KM, you need need to select the required unit.
    let us know if this is solves your problem. I am not sure if this can be done for individual queries but this is controlled by UOM wise as mentioned above.
    Regards,
    Rk.

Maybe you are looking for

  • Is there a way to save a table in Photoshop (that was created in InDesign) without fuzzy text?

    I am trying to save a table in Photoshop that was created in InDesign for web use. When I save it as a png (can't save as pdf or jpeg due to limitations with our company's website), the text appears fuzzy (pixelated?). Is this because the table is ge

  • Potential Windows Update database error detected 0x80070490

    This is the response I get when I run the Windows update troubleshooter from the Windows 8.1 Action Center.  If I click next it reports the errors have been fixed.  However if I run it again it reports exactly the same errors. After searching the Int

  • Problem Migrating Data Via Firewire

    I am trying to transfer data from G4 desktop to a Intel iMac. The G4 desktop has 2 internal drives and has 10.4.10 installed. When I boot up the G5 iMac for the initial setup, I choose the option to migrate my information from another Mac. I follow a

  • IPod Screen Lock

    My iPod was accidentally screen locked. I was playing around with it and did it on accident and now I can't get the correct password and it won't let me access it. I tried the combination I thought I had used but nothing seems to work. The problem is

  • Why can't I see still images in the playback monitor when editing a video?

    Why can't I see still images in the playback monitor when editing a video? I have rendered the images in the project.  I checked my system to make sure it meets all the requirements for the software, no problem there.  When I "share" the project and