Select Query optimisation

Hi.
Is there any way to optimise the below code. or can i write a join query for this if yes then how.
  SELECT land1
         zone1
    FROM tzone
    INTO CORRESPONDING FIELDS OF TABLE t_land
    FOR ALL ENTRIES IN int_delivery
    WHERE zone1 = int_delivery-zone1.
  IF sy-subrc = 0.
    SELECT land1
           landx
      FROM t005t
      INTO CORRESPONDING FIELDS OF TABLE t_landx
      FOR ALL ENTRIES IN t_land
      WHERE land1 = t_land-land1.
  ENDIF.
Thanks
Any help will not go unappreciated..

hi,
<i>how to optimize ?</i>
1. Avoid
INTO CORRESPONDING
, create an internal table with required fields only.
2.
select tzone~land1 tzone~zone1 t005~landx
from tzone
join t005t
on tzone~land1 = t005t~land1
into table t_landx
for all entries in int_delivery
where
tzone~zone1 = int_delivery-zone1
AND spras = sy-langu.
Regards
Anver

Similar Messages

  • Need help in optimisation for a select query on a large table

    Hi Gurus
    Please help in optimising the code. It takes 1 hr for 3-4000 records. Its very slow.
    My Select is reading from a table which contains 10 Million records.
    I am writing the select on large table and Retrieving the values from large tables by comparing my table which has 3-4 k records.
    I am pasting the code. please help
    Data: wa_i_tab1 type tys_tg_1 .
    DATA: i_tab TYPE STANDARD TABLE OF tys_tg_1.
    Data : wa_result_pkg type tys_tg_1,
    wa_result_pkg1 type tys_tg_1.
    SELECT /BIC/ZSETLRUN AGREEMENT /BIC/ZREB_SDAT /BIC/ZLITEM1 from
    /BIC/PZREB_SDAT *******************THIS TABLE CONTAINS 10 MILLION RECORDS
    into CORRESPONDING FIELDS OF table i_tab
    FOR ALL ENTRIES IN RESULT_PACKAGE***************CONTAINS 3000-4000 RECORDS
    where
    /bic/ZREB_SDAT = RESULT_PACKAGE-/BIC/ZREB_SDAT
    AND
    AGREEMENT = RESULT_PACKAGE-AGREEMENT
    AND /BIC/ZLITEM1 = RESULT_PACKAGE-/BIC/ZLITEM1.
    sort RESULT_PACKAGE by AGREEMENT /BIC/ZREB_SDAT /BIC/ZLITEM1.
    sort i_tab by AGREEMENT /BIC/ZREB_SDAT /BIC/ZLITEM1.
    loop at RESULT_PACKAGE into wa_result_pkg.
    read TABLE i_tab INTO wa_i_tab1 with key
    /BIC/ZREB_SDAT =
    wa_result_pkg-/BIC/ZREB_SDAT
    AGREEMENT = wa_result_pkg-AGREEMENT
    /BIC/ZLITEM1 = wa_result_pkg-/BIC/ZLITEM1.
    IF SY-SUBRC = 0.
    move wa_i_tab1-/BIC/ZSETLRUN to
    wa_result_pkg-/BIC/ZSETLRUN.
    wa_result_pkg1-/BIC/ZSETLRUN = wa_result_pkg-/BIC/ZSETLRUN.
    modify RESULT_PACKAGE from wa_result_pkg1
    TRANSPORTING /BIC/ZSETLRUN.
    ENDIF.
    CLEAR: wa_i_tab1,wa_result_pkg1,wa_result_pkg.
    endloop.

    Hi,
    1) RESULT_PACKAGE internal table contains any duplicate records or not bassed on the where condotion like below
    2) Remove the into CORRESPONDING FIELDS OF table instead of that into table use.
    refer the below code is
    RESULT_PACKAGE1[] = RESULT_PACKAGE[].
    sort RESULT_PACKAGE1 by /BIC/ZREB_SDAT AGREEMENT /BIC/ZLITEM1.
    delete adjustant duplicate form RESULT_PACKAGE1 comparing /BIC/ZREB_SDAT AGREEMENT /BIC/ZLITEM1.
    SELECT /BIC/ZSETLRUN AGREEMENT /BIC/ZREB_SDAT /BIC/ZLITEM1
    from /BIC/PZREB_SDAT
    into table i_tab
    FOR ALL ENTRIES IN RESULT_PACKAGE1
    where
    /bic/ZREB_SDAT = RESULT_PACKAGE1-/BIC/ZREB_SDAT
    AND
    AGREEMENT = RESULT_PACKAGE1-AGREEMENT
    AND /BIC/ZLITEM1 = RESULT_PACKAGE1-/BIC/ZLITEM1.
    and one more thing your getting 10 million records so use package size in you select query.
    Refer the following link also For All Entry for 1 Million Records
    Regards,
    Dhina..
    Edited by: Dhina DMD on Sep 15, 2011 7:17 AM

  • Doubt In a Select Query..

    Hi..
    I have a Doubt in a simple Query from the table NAST.
    My query is as follows:--
    Select kappl
           objky
           kschl
           parnr
           parvw
           nacha
           vsztp
    from nast into table vit_nast
    where kappl =   p_kappl
    and   kschl in s_kschl
    and   parnr in s_parnr
    and   nacha =   p_nacha
    and   vsztp in s_vsztp.
    Now I want to select all the NAST records which are either not processed (NAST-VSTAT = 0) or incompletely processed (NAST-VSTAT = 2)(the field in the table NAST is VSTAT which denotes the Processing status of message)
    So Can I add both the conditions in the WHERE clause of the the above Select Query?
    Is there any other optimised way I can do that?
    Thanks

    ranges: r_stat for nast-vstat.
    r_stat-low = '0'.
    r_stat-option = 'EQ'.
    r_stat-sign = 'I'.
    append r_stat.
    clear r_stat.
    r_stat-low = '2'.
    r_stat-option = 'EQ'.
    r_stat-sign = 'I'.
    append r_stat.
    clear r_stat.
    Select kappl
    objky
    kschl
    parnr
    parvw
    nacha
    vsztp
    from nast into table vit_nast
    where kappl = p_kappl
    and kschl in s_kschl
    and parnr in s_parnr
    and nacha = p_nacha
    and vsztp in s_vsztp
    <b>and vstat in r_stat.</b>
    check this..
    Regards
    vijay

  • (view hint or Query  writing method) using views in Select Query

    Need Assistance,
    Hi all,
    My database having many views. while i am joining the views in a select query increase the cost of the querys due to the complex joins in the conditions.
    While checking the select query with views individualy taking less cost.
    Does any hint or query writing method is availabe to avoid the merging of the execution plan of the views?
    I have browsed many related to the mentioned issues,couldn't found any thing that helps me.
    Please help me on this issue,it will be very much helpfull for me.
    Thanks,
    Senthur

    Please read the two threads linked to in the FAQ: {message:id=9360003} and post the relevant details they request, so that people can help you better with your issue.
    We cannot help if you just say "my query is slow what do I do to fix it" as we cannot see your queries, your data, or any other information we would need to help. If the answer was that simple, it would be built into oracle so that the optimiser would fix it for you.

  • Query Optimisation Problem

    Hi
    I have a problem regarding query optimisation, and in particularly one query. The query I have is for a view, and when I ran the cost on it, there were full table scans, and some costs were quite high:
    Select a.name, b.id, c.date
    from table a,
    table b,
    table c
    where a.id = b.id(+) and
    decode(a.version, null, a.num, a.version) = b.version(+) and
    a.id = c.id and
    b.type is null
    My question is whether this query can be made more efficient by removing the outer joins. I was thinking whether this could be carried out by some union or intersect query with an outer select. Is this possible, if so, what would be the best alternative query?
    Thanks

    Hi,
    Is b.type a NOT null column? Is the reason why you have b.type is null .. is to exclude the records that are present in both tableA and tableB, In that case try and see if this gives you the same result.
    select a.name,
           a.id,
           c.date
      from table1 a, table3 c
    where a.id = c.id
       and not exists
              (select 1
                 from table2 b
                where a.id = b.id
                  and nvl (a.version, a.num) = b.version)Make sure you have gathered statistics on the tables.
    And as sb92075 said above. Always mark a thread as answered once you get the answer. You need to help the forum as well rather than just taking help from the forum.
    G.

  • Questions on the most efficient select query..

    What is the difference between the two select query & please explain y is the 2nd select query more efficient??
    DATA: MAX_MSGNR type t100-msgnr.
    MAX_MSGNR = '000'.
    SELECT * FROM T100 INTO T100_WA
      WHERE SPRSL = 'D' AND
            ARBGB = '00'.
      CHECK: T100_WA-MSGNR > MAX_MSGNR.
      MAX_MSGNR = T100_WA-MSGNR.
    ENDSELECT.
    DATA: MAX_MSGNR type t100-msgnr.
    SELECT MAX( MSGNR ) FROM T100 INTO max_msgnr
      WHERE SPRSL = 'D' AND
            ARBGB = '00'.

    Hi,
    First never use Check statement in the Select.
    Next thing Select ... end select.
    Coming to ur question In case of first select it will fetch each record from the data base and compares that record value with the variable(MAX_MSGNR) and assigns the value to the variable. And this process will continue till the select reads all the records of the data base. Also these operations happens on the data base server. SO this query not only affect ur program but also others who is accessing the same data base.
    Second query is most efficient because of the aggregate function MAX. Here it will fetch all the records in single go and checks the max value for that column using
    optimising algorithm. So number of checks, assignments(single assignment) and fetches will be less compared to first select. This is the main reason. Hope this clarified ur doubt.
    Another thing is in first query we are selecting all the fields where as in second we are selecting only one field(required)
    Thanks,
    Vinod.
    Edited by: Vinod Kumar Vemuru on Mar 13, 2008 4:55 PM

  • Need to use Hint for Select Query  11g

    Hi,
    I have a select query which is fetching data from multiple table.
    I just need 10 or less rows, already I m using rownum <=10
    Could you tell which is the better choice for using HINT.
    /*+ FIRST_ROWS(10) */      (or)    /*+ all_rows */
    Thanks.

    On Oracle 11.2.0.3 and 11.1.0.7 on my test table with an ORDER BY in the query, I found FIRST_ROWS using the index to get sorted rows and ALL_ROWS retrieving 10 rows from a full scan and then sorting them.
    On Oracle  I didn't find any difference in plan on a different, physically smaller, table.
    For the ALL_ROWS version the optimiser already knows that there will only be 10 rows returned.
    The performance difference: As usual, only use FIRST_ROWS if you actually intend to fetch less than the full data set. If you intend to fetch all 10 rows, use ALL_ROWS, which should be the default (taken from the optimizer_mode system parameter).

  • Can someone explain this crazy query optimisation?

    A software company has me trialling a product that has a query optimiser. I can't for the life of me explain what is going on below and would like some help from someone with a bit more SQL experience. I have a query I've been struggling to bring down the time on:
    CREATE OR REPLACE VIEW PLATE_STATS_DATA_VIEW AS
    SELECT P.Folder_ID, P.expt_or_control_ID, P.Plate_Type, P.Dose_Weight, P.Volume, P.Strain_Code, P.S9_Plus,
    P.type_Name as Contents, P.Replicate_ID,
    P.Number_Of_Plates, round(avg(P.count)) as mean_count,
    min(P.count) as min_count, max(P.count) as max_count, count(P.count) as Plates_Counted
    FROM expt_folder_plates P, History_Control_Log L
    WHERE P.expt_or_control_ID = L.Control_ID
    AND P.Strain_Code = L.Strain_Code
    AND P.Plate_Type = L.Type_Code
    AND P.S9_Plus = L.S9_Plus
    AND L.control_Included > 0
    GROUP BY P.Folder_ID, P.expt_or_control_ID, P.Plate_Type, P.Dose_Weight, P.Volume, P.Strain_Code,
    P.S9_Plus, P.type_Name, P.Replicate_ID, P.Number_Of_PlatesIt took 20 seconds on my large test database, so I put it through the optimiser. It took it down to 0.1 seconds simply by changing 'WHERE P.expt_or_control_ID = L.Control_ID' to 'WHERE P.expt_or_control_ID = L.Control_ID + 0'.
    I have no idea why this would make any difference - adding zero to a value?! Can anyone enlighten me?
    Many thanks,
    Gary
    Message was edited by:
    GaryKyle

    Ahhh, thanks guys. I'm a bit of a beginner here. This is my first look at explain plans - just had to work out how to see them! I think I understand what is happening now - it looks like that with the index, it does the group by FIRST on all the data and this takes a large amount of time. Am I right?
    Before +0:
    SELECT STATEMENT, GOAL = ALL_ROWS               Cost=162787Cardinality=1380965Bytes=328669670
    SORT GROUP BY               Cost=162787     Cardinality=1380965     Bytes=328669670
      HASH JOIN               Cost=16773     Cardinality=1380965     Bytes=328669670
       TABLE ACCESS FULL     Object owner=PI_AMES_BIG     Object name=EXPT_FOLDER_DETAILS     Cost=29Cardinality=4038Bytes=387648
       HASH JOIN               Cost=16730     Cardinality=1380965     Bytes=196097030
        TABLE ACCESS FULL     Object owner=PI_AMES_BIG     Object name=AMES_PLATE_TYPES     Cost=2Cardinality=6Bytes=192
        HASH JOIN               Cost=16715     Cardinality=1380965     Bytes=151906150
         TABLE ACCESS FULL     Object owner=PI_AMES_BIG     Object name=HISTORY_CONTROL_LOG     Cost=2Cardinality=40Bytes=880
         HASH JOIN               Cost=16694     Cardinality=2002400     Bytes=176211200
          HASH JOIN               Cost=59     Cardinality=8076     Bytes=282660
           TABLE ACCESS FULL     Object owner=PI_AMES_BIG     Object name=EXPT_FOLDER_SOLVENTSCost=2Cardinality=3Bytes=51
           TABLE ACCESS FULL     Object owner=PI_AMES_BIG     Object name=CONTROLSCost=56Cardinality=8078Bytes=145404
          TABLE ACCESS FULL     Object owner=PI_AMES_BIGObject name=EXPT_FOLDER_PLATESCost=16584Cardinality=5499657Bytes=291481821After +0:
    SELECT STATEMENT, GOAL = ALL_ROWS               Cost=1655     Cardinality=138     Bytes=45954
    HASH JOIN               Cost=1655     Cardinality=138     Bytes=45954
      HASH JOIN               Cost=1625     Cardinality=138     Bytes=33672
       HASH JOIN               Cost=1569     Cardinality=414     Bytes=96462
        MERGE JOIN CARTESIAN     Cost=4          Cardinality=18     Bytes=630
         TABLE ACCESS FULL          Object owner=PI_AMES_BIG     Object name=EXPT_FOLDER_SOLVENTSCost=2Cardinality=3Bytes=30
         BUFFER SORT          Cost=2     Cardinality=6     Bytes=150
          TABLE ACCESS FULL          Object owner=PI_AMES_BIG     Object name=AMES_PLATE_TYPESCost=1     Cardinality=6Bytes=150
        VIEW               Object owner=PI_AMES_BIG     Object name=TEST_PLATE_STATSCost=1564Cardinality=138Bytes=27324
         SORT GROUP BY               Cost=1564     Cardinality=138     Bytes=10350
          TABLE ACCESS BY INDEX ROWID     Object owner=PI_AMES_BIGObject name=EXPT_FOLDER_PLATESCost=39Cardinality=3Bytes=159
           NESTED LOOPS               Cost=1563     Cardinality=138     Bytes=10350
            TABLE ACCESS FULL     Object owner=PI_AMES_BIG     Object name=HISTORY_CONTROL_LOG     Cost=2Cardinality=40Bytes=880
            INDEX RANGE SCAN     Object owner=PI_AMES_BIG     Object name=EXPT_CONTROL_ID_INDEXCost=5Cardinality=248     
       TABLE ACCESS FULL     Object owner=PI_AMES_BIG     Object name=CONTROLSCost=56     Cardinality=8078Bytes=88858
      TABLE ACCESS FULL     Object owner=PI_AMES_BIG     Object name=EXPT_FOLDER_DETAILS     Cost=29     Cardinality=4038Bytes=359382Thanks again,
    Gary
    P.S. looks like the explain plan's made the post horribly wide again ;) sorry. I'll keep it this way though otherwise the plan is hard to read.

  • Select Query Problem

    Hi Experts,
    I am having a select query in which I am using a variable in the where condition but it is giving error. Please suggest how to use variable in the select query.
    The query I am using is a s below.
    select * from zexc_rec into table it_ZEXC_REC
          where
           LIFNR in S_LIFNR and
          DOCNO in S_DOCNO and
          DOCTYP in doc_typ and
          DATE1 in S_DATE1 and
          MATNR in S_MATNR.
    Here doc_typ is a variable.
    Thanks.

    Rahul,
    use RANGES type variable instead of variable . It acts as a select-options variable. Thn use this variable in SELECT query with IN.
    Eg :
    RANGES r_t510 FOR t510-lgart.
        r_t510-low = '1600'. 
        APPEND r_t510.
        r_t510-low = '3190'. 
        APPEND r_t510.
    Note  : can be use SIGN, OPTIONS properties too in RANGES type.
    More deatils go through on HELP of RANGES
    Rgds,
    Ranjith

  • Oracle 11g :SELECT query blocked..??

    Hi Experts,
    could you please explain why the below SQL query is blocked?
    SELECT 1 FROM DUAL is blocking the SQL statement on GTTAPPUSR@gttccuatcriba04 ( SID=469 ) blocked SQL -> DELETE FROM GTTDB.PURCHASE_ENTRY_ID=:1
    SELECT 1 FROM DUAL is blocking the SQL statement on GTTAPPUSR@gttccuatcriba04 ( SID=367 ) blocked SQL -> DELETE FROM GTTDB.PURCHASE_ENTRY_ID=:1
    I am scratching my head without any solution when I had a look at the db today. Thanks in advance for your help.
    Regards,
    Boris
    Edited by: user12075620 on Dec 4, 2012 8:58 AM

    The SELECT statement is not blocking the UPDATE. As I said in the previous reply, the string that this query produces does not match the logic.
    This query is (at least on the surface) correctly identifying that session 1 is blocking session 2. Session 1 holds some lock that session 2 is waiting on. So far, so good. Since session 2 is waiting on the lock, we can easily enough see what session 2 is running (the UPDATE statement). But since session 1 is not blocked, it is potentially off running a ton of other SQL statements (or no SQL statement at all). The query is looking to see what session 1 is running currently. It has no way of determining what session 1 ran at some point in the past to acquire the lock in the first place.
    Going back to my KING example,
    At noon, session 1 runs
    UPDATE emp
       SET sal = sal * 2
    WHERE ename = 'KING'Session 1 now has a lock on the KING row in the EMP table. But session 1 neither commits nor rolls back, it is still in a transaction. Session 1 might not have any more activity for a long time-- the user might go off to lunch, for example (obviously, applications should not be designed to allow users to maintain open transactions indefinitely, but not all applications are designed correctly). Or it might start running other queries. Let's say that session 1 now runs a query that is going to go for an hour
    SELECT *
      FROM giant_view_with_lots_of_computationsNow, at 12:45, session 2 comes in and runs
    UPDATE emp
       SET bonus = 100
    WHERE ename = 'KING'Session 2 is blocked. Session 2 is running the UPDATE statement. Session 1 still holds the lock but it is running some completely unrelated SQL statement.
    If we run the query you posted, the query will correctly report that session 1 is running the query against the GIANT_VIEW_WITH_LOTS_OF_COMPUTATIONS but incorrectly imply that this SELECT query is the source of the lock. It is not. It simply happens to be the query that the session that does hold the lock happens to be executing at the current moment (why the application seems to be running a lot of queries that select a constant from dual is a separate question).
    Justin

  • Oracle SQL Select query takes long time than expected.

    Hi,
    I am facing a problem in SQL select query statement. There is a long time taken in select query from the Database.
    The query is as follows.
    select /*+rule */ f1.id,f1.fdn,p1.attr_name,p1.attr_value from fdnmappingtable f1,parametertable p1 where p1.id = f1.id and ((f1.object_type ='ne_sub_type.780' )) and ( (f1.id in(select id from fdnmappingtable where fdn like '0=#1#/14=#S0058-3#/17=#S0058-3#/18=#1#/780=#5#%')))order by f1.id asc
    This query is taking more than 4 seconds to get the results in a system where the DB is running for more than 1 month.
    The same query is taking very few milliseconds (50-100ms) in a system where the DB is freshly installed and the data in the tables are same in both the systems.
    Kindly advice what is going wrong??
    Regards,
    Purushotham

    SQL> @/alcatel/omc1/data/query.sql
    2 ;
    9 rows selected.
    Execution Plan
    Plan hash value: 3745571015
    | Id | Operation | Name |
    | 0 | SELECT STATEMENT | |
    | 1 | SORT ORDER BY | |
    | 2 | NESTED LOOPS | |
    | 3 | NESTED LOOPS | |
    | 4 | TABLE ACCESS FULL | PARAMETERTABLE |
    |* 5 | TABLE ACCESS BY INDEX ROWID| FDNMAPPINGTABLE |
    |* 6 | INDEX UNIQUE SCAN | PRIMARY_KY_FDNMAPPINGTABLE |
    |* 7 | TABLE ACCESS BY INDEX ROWID | FDNMAPPINGTABLE |
    |* 8 | INDEX UNIQUE SCAN | PRIMARY_KY_FDNMAPPINGTABLE |
    Predicate Information (identified by operation id):
    5 - filter("F1"."OBJECT_TYPE"='ne_sub_type.780')
    6 - access("P1"."ID"="F1"."ID")
    7 - filter("FDN" LIKE '0=#1#/14=#S0058-3#/17=#S0058-3#/18=#1#/780=#5#
    8 - access("F1"."ID"="ID")
    Note
    - rule based optimizer used (consider using cbo)
    Statistics
    0 recursive calls
    0 db block gets
    0 consistent gets
    0 physical reads
    0 redo size
    0 bytes sent via SQL*Net to client
    0 bytes received via SQL*Net from client
    0 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    9 rows processed
    SQL>

  • Select query differences between oracle 9 and oracle 8.

    Hi,
    I have a problem using the select query between oracle 7 and oracle 9i I don't have the same result :
    ex:
    With oracle7
    SQL> select 'champ1','champ2' from DUAL;
    'CHAMP 'CHAMP
    champ1 champ2
    With Oracle 9
    SQL> select 'champ1','champ2' from DUAL;
    'CHAMP1' 'CHAMP2'
    champ1 champ2
    So Can someone tell me how to solve this problem ? Is there a parameter in oracle 9 to set?
    Thanx.

    Whenever you are posting anything over internet forums like this - you should be very careful about not just posting the details which requires to solve the problem - also should be sensible about your question.
    This is not at all desired when you are posting such question. It may be because - you may not well aware of the fact.
    My suggestion is -> First Go through the basics Of SQL in general.
    Then go for any specific product like Oracle/ SQL Server/ Sybase etc.
    And, finally learn the advanced commands of that DB.
    You asked it - may be you thought the difference in output in terms of lines. But, that is not your actual output. That is the graphical display part only.
    Anyway,
    You can get the quite familier output by first type the following command ->
    set lin 310Regards.
    Satyaki De.

  • Select Query resulting in Scientific Notation

    Hello all,
    I am running a Select query through a batch file that extracts data from an Oracle database. Several of the fields that I am extracting from contain numbers that are up to 38 digits long. When I extract the data, it converts the numbers into scientific notation and it is important for me to have the entire field. Is there something I can change to my query that will pull the data in its entire form? This is what I'm running now:
    select * FROM ML.APPT where APPTDATE >= to_date('01/1/2010','mm/dd/yyyy'
    I apologize in advance if this has been answered already.
    Thanks!

    >
    When the extractor finishes, it returns the data into a flat file.
    don't quite understand the TO_CHAR function. Does this function mean I need to say something like this: select "TO_CHAR('column name', 99999999999999999999999999999999999999" FROM ML.APPT where APPTDATE >= to_date('01/1/2010','mm/dd/yyyy')
    >
    Yes- if the tool you use to extract the data (your 'extractor') is converting the numeric data to a string then it is responsible for creating the string in the proper format. If the number is an integer that can have as many digits as you have '9's in your sample format string then that is what you need to do.
    Here is how sql*plus (Oracle's tool) will display the data using default settings
    SQL> select 12345678901234567890123456789012345678 no_format,
      2  to_char(12345678901234567890123456789012345678, '99999999999999999999999999
    999999999999') with_format
      3   from dual;
    NO_FORMAT WITH_FORMAT
    1.2346E+37  12345678901234567890123456789012345678
    SQL>
    ----- TOAD will display something similiar but the default uses more decimal digits in the scientific notation data
    NO_FORMAT,WITH_FORMAT
    1.23456789012346E37, 12345678901234567890123456789012345678You can either format the numeric data in the query using TO_CHAR or the 'extractor' can do it when it converts the data to a string.

  • Select-options in SELECT query - syntax error

    Hi all,
      I get the error below when I try to use the select options in a SELECT query . Please help me.
    "The IN operator with "SO_AWART" is followed neither by an internal
    table nor by a value list."
    The code i have used(Logical database  PNP is used):
    TABLES: pernr,
            catsdb.
    INCLUDE ztime_cwtr_top.    " global Data
    INCLUDE ztime_cwtr_f01.
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME.
    SELECT-OPTIONS SO_AWART FOR CATSDB-AWART.
    PARAMETERS P_THRES TYPE I.
    SELECTION-SCREEN END OF BLOCK B1.
    Get data from CATSDB table. Workdates within the date interval are considered.
      SELECT pernr workdate awart catsquantity beguz enduz status
      FROM catsdb
      INTO TABLE it_catsdb
      WHERE pernr  = pernr-pernr    AND
           workdate GE pn-begda     AND
           workdate LE pn-endda     AND
           status   IN ('20', '30') AND
           awart    IN  so_awart .
          awart    IN ('1100', '1137', '1138', '1139', '1140',
                      '1147', '1148', '1149', '1157', '2003' ).
    when I give the values directly i do not get any syntax error, but when I use select options in the where condition I get the syntax error.
    I have tried different options like using only the select-options in the where condition.
    Thanks in advance.....
    Madhu

    Solved.
    Code with syntax error:
    include z...top .
    include z...fo1.
    select-options: xxxxxxx
    Code  with no syntax error:
    select-options: xxxxxxx
    include z...top .
    include z...fo1.
    Thanks for all your help,
    Madhu

  • Query in Select query operation

    Please excuse me for posting this again.
    I'm stuck up with this for 3 days. Lenghty post pls do read and help me.
    How is the select query going to be changed in the SAP so that the original database behind it understands it. I want to know the operation of IN operation in where clause where in we can use ranges.
    I'm asking this because I'm facing a problem using Native SQL.
    Query is like this:
    EXEC SQl.
    OPEN C1 for
    SELECT field1 from table@domain where field2 IN :ABAP_VAR.
    ENDEXEC.
    EXEC SQL.
    FETCH C1 NEXT INTO :VAR1 , :VAR2
    ENDEXEC.
    Oracle usually recognises this statement IN ( '2222' , '3658' , '6895' )
    But here this field that is build dynamically like this is not recognising them as seperate fileds but instead it is taking them as a single string and not selecting anything.
    But if a single value is passed it is fetching the data into the cursor. And the code is working fine.
    Any help in this is highly appreciable.

    "if a in r_range" is is effectively: does the value held in 'a' comply with the values held in range 'r_range'. Ranges can hold NE, patterns etc so this can get quite complex.
    You can see that it is very different from the SQL type IN.
    If your range hold several values you could unstrip it into a string varaible so that it ended up having a value something like: ( '2222' , '3658' , '6895' ). Not sure if you need the '(' but it would be something like this:
    eg,
    assuming your range is simple and only holds 'I' and 'EQ' values:
    data v_string type string.
    loop at r_range.
    concatenate v_string '@''' r_range-low  '''@' into v_string.
    endloop.
    REPLACE
      ALL OCCURRENCES OF '@'
      IN v_string
      WITH ' '.
    Then you can use:
    SELECT field1 from table@domain where field2 IN :v_string.

Maybe you are looking for

  • Startup Error - Worried About Recovering Data - Need Help!

    Hi All... This is my first time posting to the forum, and I'm hoping someone can help me. Last night, I used my MacBook Pro (specifics are pasted below) with no issues at the airport. I then boarded my flight, stowed my laptop under my seat, and land

  • Where can we put the nice messag

    Hey hey creative,?Just needed to go to your site for some downloads. Awesome download speeds and... very nice new website!I am very happy with my Creative T20 speakers and also with my other creative products (mp3 player, mouse and sound card!).Just

  • Flash 8: Import video clip - no playback on website

    So for the first time I imported a video clip into Flash 8, used the wizard and even found a tutorial that basically walked me through the steps of the flash wizard. I imported a clip from my computer, progressive download from web server, tried both

  • Domain functional levels

    Good afternoon, Next week I'm going to start upgrading all of our domain controllers with brand new rack mounted servers.  We currently have 3 domain controllers in different cities, all three running Windows Server 2008 R2.  All 3 of the new servers

  • Airport Hardware not Found

    I have a G4 15" iBook witrh an Airport Exteme internal card. 1 GB memory For the past month or so I have had wireless connectivity problems. I know lots of people have:-( Mine manifests itself with no recognition of the existance of the internal airp