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

Similar Messages

  • Need help in optimising the performance of a query

    Need help in optimising the performance of a query. Below is the query that is executed on TABLE_A, TABLE_B and TABLE_C with record counts as 10M, 10m and 42 (only) respectively and it takes around 5-7 minutes to get 40 records:
    SELECT DISTINCT a.T_ID_, a.FIRSTNAME, b.T_CODE, b.PRODUCT,
    CASE WHEN TRUNC(b.DATE) +90 = TRUNC(SYSDATE) THEN -90 WHEN TRUNC(b.DATE) +30 = TRUNC(SYSDATE) THEN -30 ELSE 0 END AS T_DATE FROM TABLE_B b
    INNER JOIN TABLE_A a ON (a.T_ID_ = b.T_ID_) LEFT JOIN TABLE_C c ON b.PRODUCT = c.PRODUCT
    WHERE b.STATUS = 'T' AND (b.TYPE = 'ACTION'
    AND ( TRUNC(b.DATE) + 1 = TRUNC(SYSDATE) ) ) AND b.PRODUCT = 2;
    Note: Indices on the join columns are available in the respective tables
    Please let me know if there is any better way to write it.
    Edited by: 862944 on Aug 18, 2011 9:52 AM

    862944 wrote:
    Need help in optimising the performance of a query. Below is the query that is executed on TABLE_A, TABLE_B and TABLE_C with record counts as 10M, 10m and 42 (only) respectively and it takes around 5-7 minutes to get 40 records:
    SELECT DISTINCT a.T_ID_, a.FIRSTNAME, b.T_CODE, b.PRODUCT,
    CASE WHEN TRUNC(b.DATE) +90 = TRUNC(SYSDATE) THEN -90 WHEN TRUNC(b.DATE) +30 = TRUNC(SYSDATE) THEN -30 ELSE 0 END AS T_DATE FROM TABLE_B b
    INNER JOIN TABLE_A a ON (a.T_ID_ = b.T_ID_) LEFT JOIN TABLE_C c ON b.PRODUCT = c.PRODUCT
    WHERE b.STATUS = 'T' AND (b.TYPE = 'ACTION'
    AND ( TRUNC(b.DATE) + 1 = TRUNC(SYSDATE) ) ) AND b.PRODUCT = 2;
    Note: Indices on the join columns are available in the respective tables
    Please let me know if there is any better way to write it.
    Edited by: 862944 on Aug 18, 2011 9:52 AM[When Your Query Takes Too Long|https://forums.oracle.com/forums/thread.jspa?messageID=1812597]

  • Need a drop down for a selection screen

    HI all,
    I need a drop down for a selection screen.
    say for eg: Field is MARA-MTART   (Material Type). The selection is optional and the dropdown should be using check table: T134
    How to get a dropdown? I think a function module is used , but I dont remember the name.
    Kindly reply.
    Thanks in advance.
    Points will be rewarded

    Hi,
    chk the below code...
    TYPE-POOLS: vrm.
    PARAMETER: pr_spart TYPE spart AS LISTBOX VISIBLE LENGTH 7.
    *AT SELECTION-SCREEN ON VALUE-REQUEST FOR pr_spart.
    INITIALIZATION.
    *----Code for Drop down list....
      DATA: lit_spart_list  TYPE vrm_values, "Table for list of Divisions
              lwa_spart_list TYPE vrm_value,
              lw_name  TYPE vrm_id.            "Name of parameter with list-box.
    *---Assign selected values to table that would be passed to FM VRM_SET_VALUES
      CLEAR : lwa_spart_list,
              lw_name.
    *---Pass required values for list-box display.
      lwa_spart_list-key = 'H'.
      lwa_spart_list-text = 'HL'.
      APPEND lwa_spart_list TO lit_spart_list.
      lwa_spart_list-key = 'S'.
      lwa_spart_list-text = 'SL'.
      APPEND lwa_spart_list TO lit_spart_list.
      lwa_spart_list-key = 'P'.
      lwa_spart_list-text = 'PP'.
      APPEND lwa_spart_list TO lit_spart_list.
      lwa_spart_list-key = 'F'.
      lwa_spart_list-text = 'FR'.
      APPEND lwa_spart_list TO lit_spart_list.
    *Name of parameter to which list is to be assigned
      lw_name = 'PR_SPART'.
      CALL FUNCTION 'VRM_SET_VALUES'
        EXPORTING
          id              = lw_name
          values          = lit_spart_list
        EXCEPTIONS
          id_illegal_name = 1
          OTHERS          = 2.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    Reagrds,
    nagaraj

  • I need help choosing RAM for MSI PM8PM-V 7222 VER. 2.0 MB

    hey everyone as you know my MB is in the subject and i need help buying ram for it. on the MSI website it says it can surpport max. 2GB so 1GB in each slot? it only has 2 slots also what DDR and MHZ clock, DRAM fequency etc does the ram have to be and both single sided or double sided or 1 single and 1 double?
    thanks

    Quote
    also what DDR and MHZ clock, DRAM fequency etc does the ram have to be
    http://global.msi.eu/index.php?func=proddesc&maincat_no=1&prod_no=1039
    Quote
    • Supports DDR2 533/400 memory interface.
    Check the memory support list for best compatibility:
    http://global.msi.eu/uploads/test_report/TR10_1039.pdf

  • I need help finding cases for the ipod touch thrid gen help.

    i need help finding case for ipod touch thrid gen help.

    - Try another cable.
    - Try another USB port
    - Inspect the dock connector on the iPod for bent or missing contacts, foreign material, corroded contacts, broken, missing or cracked plastic.
    - Try on another computer. Just backup a couple of times. Do not sync.

  • Using case when statement in the select query to create physical table

    Hello,
    I have a requirement where in I have to execute a case when statement with a session variable while creating a physical table using a select query. let me explain with an example.
    I have a physical table based on a select table with one column.
    SELECT 'VALUEOF(NQ_SESSION.NAME_PARAMETER)' AS NAME_PARAMETER FROM DUAL. Let me call this table as the NAME_PARAMETER table.
    I also have a customer table.
    In my dashboard that has two pages, Page 1 contains a table with the customer table with column navigation to my second dashboard page.
    In my second dashboard page I created a dashboard report based on NAME_PARAMETER table and a prompt based on customer table that sets the NAME_ PARAMETER request variable.
    EXECUTION
    When i click on a particular customer, the prompt sets the variable NAME_PARAMETER and the NAME_PARAMETER table shows the appropriate customer.
    everything works as expected. YE!!
    Now i created another table called NAME_PARAMETER1 with a little modification to the earlier table. the query is as follows.
    SELECT CASE WHEN 'VALUEOF(NQ_SESSION.NAME_PARAMETER)'='Customer 1' THEN 'TEST_MART1' ELSE TEST_MART2' END AS NAME_PARAMETER
    FROM DUAL
    Now I pull in this table into the second dashboard page along with the NAME_PARAMETER table report.
    surprisingly, NAME_PARAMETER table report executes as is, but the other report based on the NAME_PARAMETER1 table fails with the following error.
    Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 16001] ODBC error state: S1000 code: 1756 message: [Oracle][ODBC][Ora]ORA-01756: quoted string not properly terminated. [nQSError: 16014] SQL statement preparation failed. (HY000)
    SQL Issued: SET VARIABLE NAME_PARAMETER='Novartis';SELECT NAME_PARAMETER.NAME_PARAMETER saw_0 FROM POC_ONE_DOT_TWO ORDER BY saw_0
    If anyone has any explanation to this error and how we can achieve the same, please help.
    Thanks.

    Hello,
    Updates :) sorry.. the error was a stupid one.. I resolved and I got stuck at my next step.
    I am creating a physical table using a select query. But I am trying to obtain the name of the table dynamically.
    Here is what I am trying to do. the select query of the physical table is as follows.
    SELECT CUSTOMER_ID AS CUSTOMER_ID, CUSTOMER_NAME AS CUSTOMER_NAME FROM 'VALUEOF(NQ_SESSION.SCHEMA_NAME)'.CUSTOMER.
    The idea behind this is to obtain the data from the same table from different schemas dynamically based on what a session variable. Please let me know if there is a way to achieve this, if not please let me know if this can be achieved in any other method in OBIEE.
    Thanks.

  • How to create an explain plan with rowsource statistics for a complex query that include multiple table joins ?

    1. How to create an explain plan with rowsource statistics for a complex query that include multiple table joins ?
    When multiple tables are involved , and the actual number of rows returned is more than what the explain plan tells. How can I find out what change is needed  in the stat plan  ?
    2. Does rowsource statistics gives some kind of  understanding of Extended stats ?

    You can get Row Source Statistics only *after* the SQL has been executed.  An Explain Plan midway cannot give you row source statistics.
    To get row source statistics either set STATISTICS_LEVEL='ALL'  in the session that executes theSQL OR use the Hint "gather_plan_statistics"  in the SQL being executed.
    Then use dbms_xplan.display_cursor
    Hemant K Chitale

  • Select Query failing on a  table that has per sec heavy insertions.

    Hi
    Problem statement
    1- We are using 11g as an database.
    2- We have a table that is partitioned on the date as range partition.
    3- The insertion of data is very high.i.e. several hundreds records per sec. in the current partitioned.
    4- The data is continuously going in the current partitioned as and when buffer is full or per sec timer expires.
    5-- We have to make also select query on the same table and on the current partitioned say for the latest 500 records.
    6- Effecient indexes are also created on the table.
    Solutions Tried.
    1- After analyzing by tkprof it is observed that select and execute is working fine but fetch is taking too much time to show the out put. Say it takes 1 hour.
    2- Using the 11g sql advisior and SPM several baseline is created but the success rate of them is observed also too low.
    please suggest any solution to this issue
    1- i.e. Redisgn of table.
    2- Any better way to quey to fix the fetch issue.
    3- Any oracle seetings or parameter changes to fix the fetch issue.
    Thanks in advance.
    Regards
    Vishal Sharma

    I am uploading the latest stats please let me know how can improve as this is taking 25 minutes
    ####TKPROF output#########
    SQL ID : 2j5w6bv437cak
    select almevttbl.AlmEvtId, almevttbl.AlmType, almevttbl.ComponentId,
      almevttbl.TimeStamp, almevttbl.Severity, almevttbl.State,
      almevttbl.Category, almevttbl.CauseCode, almevttbl.UnitType,
      almevttbl.UnitId, almevttbl.UnitName, almevttbl.ServerName,
      almevttbl.StrParam, almevttbl.ExtraStrParam, almevttbl.ExtraStrParam2,
      almevttbl.ExtraStrParam3, almevttbl.ParentCustId, almevttbl.ExtraParam1,
      almevttbl.ExtraParam2, almevttbl.ExtraParam3,almevttbl.ExtraParam4,
      almevttbl.ExtraParam5, almevttbl.SRCIPADDRFAMILY,almevttbl.SrcIPAddress11,
      almevttbl.SrcIPAddress12,almevttbl.SrcIPAddress13,almevttbl.SrcIPAddress14,
      almevttbl.DESTIPADDRFAMILY,almevttbl.DestIPAddress11,
      almevttbl.DestIPAddress12,almevttbl.DestIPAddress13,
      almevttbl.DestIPAddress14,  almevttbl.DestPort, almevttbl.SrcPort,
      almevttbl.SessionDir, almevttbl.CustomerId, almevttbl.ProfileId,
      almevttbl.ParentProfileId, almevttbl.CustomerName, almevttbl.AttkDir,
      almevttbl.SubCategory, almevttbl.RiskCategory, almevttbl.AssetValue,
      almevttbl.IPSAction, almevttbl.l4Protocol,almevttbl.ExtraStrParam4 ,
      almevttbl.ExtraStrParam5,almevttbl.username,almevttbl.ExtraStrParam6,
      IpAddrFamily1,IPAddrValue11,IPAddrValue12,IPAddrValue13,IPAddrValue14,
      IpAddrFamily2,IPAddrValue21,IPAddrValue22,IPAddrValue23,IPAddrValue24
    FROM
           AlmEvtTbl PARTITION(ALMEVTTBLP20100323) WHERE AlmEvtId IN ( SELECT  * FROM
      ( SELECT /*+ FIRST_ROWS(1000) INDEX (AlmEvtTbl AlmEvtTbl_Index) */AlmEvtId
      FROM AlmEvtTbl PARTITION(ALMEVTTBLP20100323) where       ((AlmEvtTbl.Customerid
      = 0 or AlmEvtTbl.ParentCustId = 0))  ORDER BY AlmEvtTbl.TIMESTAMP DESC) 
      WHERE ROWNUM  <  602) order by timestamp desc
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.10       0.17          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch       42   1348.25    1521.24       1956   39029545          0         601
    total       44   1348.35    1521.41       1956   39029545          0         601
    Misses in library cache during parse: 1
    Optimizer mode: FIRST_ROWS
    Parsing user id: 82 
    Rows     Row Source Operation
        601  PARTITION RANGE SINGLE PARTITION: 24 24 (cr=39029545 pr=1956 pw=1956 time=11043 us cost=0 size=7426 card=1)
        601   TABLE ACCESS BY LOCAL INDEX ROWID ALMEVTTBL PARTITION: 24 24 (cr=39029545 pr=1956 pw=1956 time=11030 us cost=0 size=7426 card=1)
        601    INDEX FULL SCAN ALMEVTTBL_INDEX PARTITION: 24 24 (cr=39029377 pr=1956 pw=1956 time=11183 us cost=0 size=0 card=1)(object id 72557)
        601     FILTER  (cr=39027139 pr=0 pw=0 time=0 us)
    169965204      COUNT STOPKEY (cr=39027139 pr=0 pw=0 time=24859073 us)
    169965204       VIEW  (cr=39027139 pr=0 pw=0 time=17070717 us cost=0 size=13 card=1)
    169965204        PARTITION RANGE SINGLE PARTITION: 24 24 (cr=39027139 pr=0 pw=0 time=13527031 us cost=0 size=48 card=1)
    169965204         TABLE ACCESS BY LOCAL INDEX ROWID ALMEVTTBL PARTITION: 24 24 (cr=39027139 pr=0 pw=0 time=10299895 us cost=0 size=48 card=1)
    169965204          INDEX FULL SCAN ALMEVTTBL_INDEX PARTITION: 24 24 (cr=1131414 pr=0 pw=0 time=3222624 us cost=0 size=0 card=1)(object id 72557)
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      SQL*Net message to client                      42        0.00          0.00
      SQL*Net message from client                    42       11.54        133.54
      db file sequential read                      1956        0.20         28.00
      latch free                                     21        0.00          0.01
      latch: cache buffers chains                     9        0.01          0.02
    SQL ID : 0ushr863b7z39
    SELECT /* OPT_DYN_SAMP */ /*+ ALL_ROWS IGNORE_WHERE_CLAUSE
      NO_PARALLEL(SAMPLESUB) opt_param('parallel_execution_enabled', 'false')
      NO_PARALLEL_INDEX(SAMPLESUB) NO_SQL_TUNE */ NVL(SUM(C1),0), NVL(SUM(C2),0)
    FROM
    (SELECT /*+ IGNORE_WHERE_CLAUSE NO_PARALLEL("PLAN_TABLE") FULL("PLAN_TABLE")
      NO_PARALLEL_INDEX("PLAN_TABLE") */ 1 AS C1, CASE WHEN
      "PLAN_TABLE"."STATEMENT_ID"=:B1 THEN 1 ELSE 0 END AS C2 FROM
      "SYS"."PLAN_TABLE$" "PLAN_TABLE") SAMPLESUB
    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.00       0.01          1          3          0           1
    total        3      0.00       0.01          1          3          0           1
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 82     (recursive depth: 1)
    Rows     Row Source Operation
          1  SORT AGGREGATE (cr=3 pr=1 pw=1 time=0 us)
          0   TABLE ACCESS FULL PLAN_TABLE$ (cr=3 pr=1 pw=1 time=0 us cost=29 size=138856 card=8168)
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      db file sequential read                         1        0.01          0.01
    SQL ID : bjkdb51at8dnb
    EXPLAIN PLAN SET STATEMENT_ID='PLUS30350011' FOR select almevttbl.AlmEvtId,
      almevttbl.AlmType, almevttbl.ComponentId, almevttbl.TimeStamp,
      almevttbl.Severity, almevttbl.State, almevttbl.Category,
      almevttbl.CauseCode, almevttbl.UnitType, almevttbl.UnitId,
      almevttbl.UnitName, almevttbl.ServerName, almevttbl.StrParam,
      almevttbl.ExtraStrParam, almevttbl.ExtraStrParam2, almevttbl.ExtraStrParam3,
       almevttbl.ParentCustId, almevttbl.ExtraParam1, almevttbl.ExtraParam2,
      almevttbl.ExtraParam3,almevttbl.ExtraParam4,almevttbl.ExtraParam5,
      almevttbl.SRCIPADDRFAMILY,almevttbl.SrcIPAddress11,almevttbl.SrcIPAddress12,
      almevttbl.SrcIPAddress13,almevttbl.SrcIPAddress14,
      almevttbl.DESTIPADDRFAMILY,almevttbl.DestIPAddress11,
      almevttbl.DestIPAddress12,almevttbl.DestIPAddress13,
      almevttbl.DestIPAddress14,  almevttbl.DestPort, almevttbl.SrcPort,
      almevttbl.SessionDir, almevttbl.CustomerId, almevttbl.ProfileId,
      almevttbl.ParentProfileId, almevttbl.CustomerName, almevttbl.AttkDir,
      almevttbl.SubCategory, almevttbl.RiskCategory, almevttbl.AssetValue,
      almevttbl.IPSAction, almevttbl.l4Protocol,almevttbl.ExtraStrParam4 ,
      almevttbl.ExtraStrParam5,almevttbl.username,almevttbl.ExtraStrParam6,
      IpAddrFamily1,IPAddrValue11,IPAddrValue12,IPAddrValue13,IPAddrValue14,
      IpAddrFamily2,IPAddrValue21,IPAddrValue22,IPAddrValue23,IPAddrValue24 FROM 
           AlmEvtTbl PARTITION(ALMEVTTBLP20100323) WHERE AlmEvtId IN ( SELECT  * FROM
      ( SELECT /*+ FIRST_ROWS(1000) INDEX (AlmEvtTbl AlmEvtTbl_Index) */AlmEvtId
      FROM AlmEvtTbl PARTITION(ALMEVTTBLP20100323) where       ((AlmEvtTbl.Customerid
      = 0 or AlmEvtTbl.ParentCustId = 0))  ORDER BY AlmEvtTbl.TIMESTAMP DESC) 
      WHERE ROWNUM  <  602) order by timestamp desc
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.28       0.26          0          0          0           0
    Execute      1      0.01       0.00          0          0          0           0
    Fetch        0      0.00       0.00          0          0          0           0
    total        2      0.29       0.27          0          0          0           0
    Misses in library cache during parse: 1
    Optimizer mode: FIRST_ROWS
    Parsing user id: 82 
    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
      SQL*Net message from client                     1        0.00          0.00
    OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
    call     count       cpu    elapsed       disk      query    current        rows
    Parse       13      0.71       0.96          3         10          0           0
    Execute     14      0.20       0.29          4        304         26          21
    Fetch       92   2402.17    2714.85       3819   70033708          0        1255
    total      119   2403.09    2716.10       3826   70034022         26        1276
    Misses in library cache during parse: 10
    Misses in library cache during execute: 6
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      SQL*Net message to client                      49        0.00          0.00
      SQL*Net message from client                    48       29.88        163.43
      db file sequential read                      1966        0.20         28.10
      latch free                                     21        0.00          0.01
      latch: cache buffers chains                     9        0.01          0.02
      latch: session allocation                       1        0.00          0.00
    OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
    call     count       cpu    elapsed       disk      query    current        rows
    Parse      940      0.51       0.73          1          2         38           0
    Execute   3263      1.93       2.62          7       1998         43          23
    Fetch     6049      1.32       4.41        214      12858         36       13724
    total    10252      3.78       7.77        222      14858        117       13747
    Misses in library cache during parse: 172
    Misses in library cache during execute: 168
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      db file sequential read                        88        0.04          0.62
      latch: shared pool                              8        0.00          0.00
      latch: row cache objects                        2        0.00          0.00
      latch free                                      1        0.00          0.00
      latch: session allocation                       1        0.00          0.00
       34  user  SQL statements in session.
    3125  internal SQL statements in session.
    3159  SQL statements in session.
    Trace file: ora11g_ora_2064.trc
    Trace file compatibility: 11.01.00
    Sort options: default
           6  sessions in tracefile.
          98  user  SQL statements in trace file.
        9111  internal SQL statements in trace file.
        3159  SQL statements in trace file.
          89  unique SQL statements in trace file.
       30341  lines in trace file.
        6810  elapsed seconds in trace file.
    ###################################### AutoTrace Output#################  
    Statistics
           3901  recursive calls
              0  db block gets
       39030275  consistent gets
           1970  physical reads
            140  redo size
         148739  bytes sent via SQL*Net to client
            860  bytes received via SQL*Net from client
             42  SQL*Net roundtrips to/from client
             73  sorts (memory)
              0  sorts (disk)
            601  rows processed

  • I need to know the proper syntax for my SELECT query, please.

    Hello All,
    Quick one for you:
    Let's say that I have several columns in a table with names such as subject_1, subject_2, subject_3, etc. The table's name is subject_names.
    The number in each of the three column name examples is also a value passed along a query string, the user can select choices, 1, 2 or 3. That query string's variable is $qs.
    So, what I want is a SELECT query that uses the query string value as follows (KEEP IN MIND, I know this is not the proper syntax):
    "SELECT subject_[$qs]
    FROM subject_names";
    I have tried all sorts of cominations of quotes (single and double), dots, brackets, braces and parenthesis. I just want to know how to include such a variable within this code.
    Any and all help is sincerely appreciated!
    Cheers,
    wordman

    Well, I did give you the syntax though.
    $query = 'SELECT ' . $qs . ' FROM tbl_name';
    I put spaces between the periods this time to make it more clear.
    If you put the actual word 'subject' in there and just want your form to name it's options as the numbers available you could do this:
    $query = 'SELECT subject_' . $qs . ' FROM tbl_name';
    In PHP you can use either single or double quotes around your query string, I always just use single quotes. I see a lot of other use double quotes.
    Double quotes would look like:
    $query = "SELECT subject_' . $qs . ' FROM tbl_name";
    Or when using double quotes you can actually just place the variable right in the string without having to concatenate multiple strings like above.
    Since you mentioned that you are good with passing variables I probably don't have to mention that you need to set the value attribute of your option tags (if you are using a select) to the value you want them to pass.
    Ex:
    <select name="choices">
         <option value="1">1</option>
         <option value="2">2</option>
         <option value="3">3</option>
    </select>
    If you have that part all figured out then you can use the syntax above for your query string.
    Good luck.

  • NEED HELP IN REDUCING THE LENGTH OF QUERY WHICH IS ATTACHED IN A FILE PL_SQ

    Hi Everyone,
    THANKS FOR POSTING THE REPLIES FOR MY LAST THREAD. THAT REALLY HELPED. I CAME BACK AGAIN BECAUSE I NEED HELP FROM THIS FORUM IN REDUING THE LENGTH OF MY QUERY WHICH I HAD GIVEN BELOW. i DIDN'T HAD THE CHOICE OF ATTACHING A FILE OF MY DATA HERE.ITS VERY HUGE DATA SO I AM NOT ABLE TO PROVIDE ATLEAST SAMPLE DATA BECAUSE THE COLUMNS ARE OVERLAPPING IF I AM PASTING THE DATA HERE. I HOPE IT WILL BE UNDERSTANDABLE. THE QUERY WHICH I WROTE IS TOO LONG AND TAKING HOURS TOGETHER TO RUN AND DISPLAY RESULT. IT WOULD BE A GREAT FAVOUR TO ME IF ANYONE CAN REDUCE THE LINES IN MY QUERY AND MAKE IT RUN FAST....PLEASE I WAS NOT KNOWING THE WAY HOW TO MAKE IT SHORT. IT HAS MANY LOGICS IN IT... :? PLEASE SUGGEST ME IF THERE IS ANY OPTION FOR ATTACHING A FILE SO THAT I CAN SEND MY SAMPLE DATA...
    select pt.product code,
    pt.product status,
    pt.store code,
    pt.store status,
    pr.scheduled date,
    pr.actual date,
    pl.scheduled date,
    pl.actual date,
    ps.scheduled date,
    ps.actual date,
    fo.scheduled date,
    fo.actual date,
    fb.scheduled date,
    fb.actual date,
    fod.scheduled date,
    fod.actual date,
    lo.scheduled date,
    lo.actual date,
    lom.scheduled date,
    lom.actual date,
    lod.scheduled date,
    lod.actual date,
    /*pr*/
    case
    WHEN pt.store status = 'Cancelled' OR
    pt.store status = 'Stopped' THEN
    cast('N/A' AS nvarchar2(30))
    WHEN pt.store status = 'Completed' OR
    pt.store status = 'Active' THEN
    NVL2(pr.scheduled date,
    cast(pr.scheduled date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Planned' THEN
    NVL2(pr.scheduled date,
    cast(pr.scheduled date AS nvarchar2(30)),
    'Null')
    end as DER_pr_SHC,
    case
    when pt.store status = 'Cancelled' OR
    pt.store status = 'Stopped' THEN
    cast('N/A' AS nvarchar2(30))
    WHEN pt.store status = 'Completed' THEN
    NVL2(pr.actual date,
    cast(pr.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    pr.scheduled date is null THEN
    NVL2(pr.actual date,
    cast(pr.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    pr.scheduled date < CURRENT_DATE THEN
    NVL2(pr.actual date,
    cast(pr.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    pr.scheduled date >= CURRENT_DATE THEN
    NVL2(pr.actual date,
    cast(pr.actual date AS nvarchar2(30)),
    'N/A')
    when pt.store status = 'Planned' and
    pr.scheduled date is null THEN
    NVL2(pr.actual date,
    cast(pr.actual date AS nvarchar2(30)),
    'N/A')
    when pt.store status = 'Planned' and
    pr.scheduled date < CURRENT_DATE THEN
    NVL2(pr.actual date,
    cast(pr.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Planned' and
    pr.scheduled date >= CURRENT_DATE THEN
    NVL2(pr.actual date,
    cast(pr.actual date AS nvarchar2(30)),
    'N/A')
    end as DER_pr_ACT,
    /*pl*/
    case
    WHEN pt.store status = 'Cancelled' OR
    pt.store status = 'Stopped' THEN
    cast('N/A' AS nvarchar2(30))
    WHEN pt.store status = 'Completed' OR
    pt.store status = 'Active' THEN
    NVL2(pl.scheduled date,
    cast(pl.scheduled date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Planned' THEN
    NVL2(pl.scheduled date,
    cast(pl.scheduled date AS nvarchar2(30)),
    'Null')
    end as DER_pl_SHC,
    case
    when pt.store status = 'Cancelled' OR
    pt.store status = 'Stopped' THEN
    cast('N/A' AS nvarchar2(30))
    WHEN pt.store status = 'Completed' THEN
    NVL2(pl.actual date,
    cast(pl.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    pl.scheduled date is null THEN
    NVL2(pl.actual date,
    cast(pl.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    pl.scheduled date < CURRENT_DATE THEN
    NVL2(pl.actual date,
    cast(pl.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    pl.scheduled date >= CURRENT_DATE THEN
    NVL2(pl.actual date,
    cast(pl.actual date AS nvarchar2(30)),
    'N/A')
    when pt.store status = 'Planned' and
    pl.scheduled date is null THEN
    NVL2(pl.actual date,
    cast(pl.actual date AS nvarchar2(30)),
    'N/A')
    when pt.store status = 'Planned' and
    pl.scheduled date < CURRENT_DATE THEN
    NVL2(pl.actual date,
    cast(pl.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Planned' and
    pl.scheduled date >= CURRENT_DATE THEN
    NVL2(pl.actual date,
    cast(pl.actual date AS nvarchar2(30)),
    'N/A')
    end as DER_pl_ACT,
    /*ps*/
    case
    WHEN pt.store status = 'Cancelled' OR
    pt.store status = 'Stopped' THEN
    cast('N/A' AS nvarchar2(30))
    WHEN pt.store status = 'Completed' OR
    pt.store status = 'Active' THEN
    NVL2(ps.scheduled date,
    cast(ps.scheduled date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'planned' THEN
    NVL2(ps.scheduled date,
    cast(ps.scheduled date AS nvarchar2(30)),
    'Null')
    end as DER_ps_SHC,
    case
    when pt.store status = 'Cancelled' OR
    pt.store status = 'Stopped' THEN
    cast('N/A' AS nvarchar2(30))
    WHEN pt.store status = 'Completed' THEN
    NVL2(ps.actual date,
    cast(ps.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    ps.scheduled date is null THEN
    NVL2(ps.actual date,
    cast(ps.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    ps.scheduled date < CURRENT_DATE THEN
    NVL2(ps.actual date,
    cast(ps.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    ps.scheduled date >= CURRENT_DATE THEN
    NVL2(ps.actual date,
    cast(ps.actual date AS nvarchar2(30)),
    'N/A')
    when pt.store status = 'planned' and
    ps.scheduled date is null THEN
    NVL2(ps.actual date,
    cast(ps.actual date AS nvarchar2(30)),
    'N/A')
    when pt.store status = 'planned' and
    ps.scheduled date < CURRENT_DATE THEN
    NVL2(ps.actual date,
    cast(ps.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'planned' and
    ps.scheduled date >= CURRENT_DATE THEN
    NVL2(ps.actual date,
    cast(ps.actual date AS nvarchar2(30)),
    'N/A')
    end as DER_ps_ACT,
    /*fo*/
    case
    WHEN pt.store status = 'Cancelled' OR
    pt.store status = 'Stopped' THEN
    cast('N/A' AS nvarchar2(30))
    WHEN pt.store status = 'Completed' OR
    pt.store status = 'Active' THEN
    NVL2(fo.scheduled date,
    cast(fo.scheduled date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'planned' THEN
    NVL2(fo.scheduled date,
    cast(fo.scheduled date AS nvarchar2(30)),
    'Null')
    end as DER_fo_SHC,
    case
    when pt.store status = 'Cancelled' OR
    pt.store status = 'Stopped' THEN
    cast('N/A' AS nvarchar2(30))
    WHEN pt.store status = 'Completed' THEN
    NVL2(fo.actual date,
    cast(fo.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    fo.scheduled date is null THEN
    NVL2(fo.actual date,
    cast(fo.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    fo.scheduled date < CURRENT_DATE THEN
    NVL2(fo.actual date,
    cast(fo.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    fo.scheduled date >= CURRENT_DATE THEN
    NVL2(fo.actual date,
    cast(fo.actual date AS nvarchar2(30)),
    'N/A')
    when pt.store status = 'planned' and
    fo.scheduled date is null THEN
    NVL2(fo.actual date,
    cast(fo.actual date AS nvarchar2(30)),
    'N/A')
    when pt.store status = 'planned' and
    fo.scheduled date < CURRENT_DATE THEN
    NVL2(fo.actual date,
    cast(fo.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'planned' and
    fo.scheduled date >= CURRENT_DATE THEN
    NVL2(fo.actual date,
    cast(fo.actual date AS nvarchar2(30)),
    'N/A')
    end as DER_fo_ACT,
    /*fb*/
    case
    WHEN pt.store status = 'Cancelled' OR
    pt.store status = 'Stopped' THEN
    cast('N/A' AS nvarchar2(30))
    WHEN pt.store status = 'Completed' OR
    pt.store status = 'Active' THEN
    NVL2(fb.scheduled date,
    cast(fb.scheduled date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'planned' THEN
    NVL2(fb.scheduled date,
    cast(fb.scheduled date AS nvarchar2(30)),
    'Null')
    end as DER_fb_SHC,
    case
    when pt.store status = 'Cancelled' OR
    pt.store status = 'Stopped' THEN
    cast('N/A' AS nvarchar2(30))
    WHEN pt.store status = 'Completed' THEN
    NVL2(fb.actual date,
    cast(fb.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    fb.scheduled date is null THEN
    NVL2(fb.actual date,
    cast(fb.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    fb.scheduled date < CURRENT_DATE THEN
    NVL2(fb.actual date,
    cast(fb.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    fb.scheduled date >= CURRENT_DATE THEN
    NVL2(fb.actual date,
    cast(fb.actual date AS nvarchar2(30)),
    'N/A')
    when pt.store status = 'planned' and
    fb.scheduled date is null THEN
    NVL2(fb.actual date,
    cast(fb.actual date AS nvarchar2(30)),
    'N/A')
    when pt.store status = 'planned' and
    fb.scheduled date < CURRENT_DATE THEN
    NVL2(fb.actual date,
    cast(fb.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'planned' and
    fb.scheduled date >= CURRENT_DATE THEN
    NVL2(fb.actual date,
    cast(fb.actual date AS nvarchar2(30)),
    'N/A')
    end as DER_fb_ACT,
    /*fod*/
    case
    WHEN pt.store status = 'Cancelled' OR
    pt.store status = 'Stopped' THEN
    cast('N/A' AS nvarchar2(30))
    WHEN pt.store status = 'Compldeted' OR
    pt.store status = 'Active' THEN
    NVL2(fod.scheduled date,
    cast(fod.scheduled date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'pldanned' THEN
    NVL2(fod.scheduled date,
    cast(fod.scheduled date AS nvarchar2(30)),
    'Null')
    end as DER_fod_SHC,
    case
    when pt.store status = 'Cancelled' OR
    pt.store status = 'Stopped' THEN
    cast('N/A' AS nvarchar2(30))
    WHEN pt.store status = 'Completed' THEN
    NVL2(fod.actual date,
    cast(fod.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    fod.scheduled date is null THEN
    NVL2(fod.actual date,
    cast(fod.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    fod.scheduled date < CURRENT_DATE THEN
    NVL2(fod.actual date,
    cast(fod.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    fod.scheduled date >= CURRENT_DATE THEN
    NVL2(fod.actual date,
    cast(fod.actual date AS nvarchar2(30)),
    'N/A')
    when pt.store status = 'planned' and
    fod.scheduled date is null THEN
    NVL2(fod.actual date,
    cast(fod.actual date AS nvarchar2(30)),
    'N/A')
    when pt.store status = 'planned' and
    fod.scheduled date < CURRENT_DATE THEN
    NVL2(fod.actual date,
    cast(fod.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'planned' and
    fod.scheduled date >= CURRENT_DATE THEN
    NVL2(fod.actual date,
    cast(fod.actual date AS nvarchar2(30)),
    'N/A')
    end as DER_fod_ACT,
    /*lo*/
    case
    WHEN pt.store status = 'Cancelled' OR
    pt.store status = 'Stopped' THEN
    cast('N/A' AS nvarchar2(30))
    WHEN pt.store status = 'Completed' OR
    pt.store status = 'Active' THEN
    NVL2(lo.scheduled date,
    cast(lo.scheduled date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'planned' THEN
    NVL2(lo.scheduled date,
    cast(lo.scheduled date AS nvarchar2(30)),
    'Null')
    end as DER_lo_SHC,
    case
    when pt.store status = 'Cancelled' OR
    pt.store status = 'Stopped' THEN
    cast('N/A' AS nvarchar2(30))
    WHEN pt.store status = 'Completed' THEN
    NVL2(lo.actual date,
    cast(lo.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    lo.scheduled date is null THEN
    NVL2(lo.actual date,
    cast(lo.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    lo.scheduled date < CURRENT_DATE THEN
    NVL2(lo.actual date,
    cast(lo.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    lo.scheduled date >= CURRENT_DATE THEN
    NVL2(lo.actual date,
    cast(lo.actual date AS nvarchar2(30)),
    'N/A')
    when pt.store status = 'planned' and
    lo.scheduled date is null THEN
    NVL2(lo.actual date,
    cast(lo.actual date AS nvarchar2(30)),
    'N/A')
    when pt.store status = 'planned' and
    lo.scheduled date < CURRENT_DATE THEN
    NVL2(lo.actual date,
    cast(lo.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'planned' and
    lo.scheduled date >= CURRENT_DATE THEN
    NVL2(lo.actual date,
    cast(lo.actual date AS nvarchar2(30)),
    'N/A')
    end as DER_lo_ACT,
    /*lom*/
    case
    WHEN pt.store status = 'Cancelled' OR
    pt.store status = 'Stopped' THEN
    cast('N/A' AS nvarchar2(30))
    WHEN pt.store status = 'Completed' OR
    pt.store status = 'Active' THEN
    NVL2(lom.scheduled date,
    cast(lom.scheduled date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'planned' THEN
    NVL2(lom.scheduled date,
    cast(lom.scheduled date AS nvarchar2(30)),
    'Null')
    end as DER_lom_SHC,
    case
    when pt.store status = 'Cancelled' OR
    pt.store status = 'Stopped' THEN
    cast('N/A' AS nvarchar2(30))
    WHEN pt.store status = 'Completed' THEN
    NVL2(lom.actual date,
    cast(lom.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    lom.scheduled date is null THEN
    NVL2(lom.actual date,
    cast(lom.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    lom.scheduled date < CURRENT_DATE THEN
    NVL2(lom.actual date,
    cast(lom.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    lom.scheduled date >= CURRENT_DATE THEN
    NVL2(lom.actual date,
    cast(lom.actual date AS nvarchar2(30)),
    'N/A')
    when pt.store status = 'planned' and
    lom.scheduled date is null THEN
    NVL2(lom.actual date,
    cast(lom.actual date AS nvarchar2(30)),
    'N/A')
    when pt.store status = 'planned' and
    lom.scheduled date < CURRENT_DATE THEN
    NVL2(lom.actual date,
    cast(lom.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'planned' and
    lom.scheduled date >= CURRENT_DATE THEN
    NVL2(lom.actual date,
    cast(lom.actual date AS nvarchar2(30)),
    'N/A')
    end as DER_lom_ACT,
    /*lod*/
    case
    WHEN pt.store status = 'Cancelled' OR
    pt.store status = 'Stopped' THEN
    cast('N/A' AS nvarchar2(30))
    WHEN pt.store status = 'Completed' OR
    pt.store status = 'Active' THEN
    NVL2(lod.scheduled date,
    cast(lod.scheduled date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'planned' THEN
    NVL2(lod.scheduled date,
    cast(lod.scheduled date AS nvarchar2(30)),
    'Null')
    end as DER_lod_SHC,
    case
    when pt.store status = 'Cancelled' OR
    pt.store status = 'Stopped' THEN
    cast('N/A' AS nvarchar2(30))
    WHEN pt.store status = 'Completed' THEN
    NVL2(lod.actual date,
    cast(lod.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    lod.scheduled date is null THEN
    NVL2(lod.actual date,
    cast(lod.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    lod.scheduled date < CURRENT_DATE THEN
    NVL2(lod.actual date,
    cast(lod.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'Active' and
    lod.scheduled date >= CURRENT_DATE THEN
    NVL2(lod.actual date,
    cast(lod.actual date AS nvarchar2(30)),
    'N/A')
    when pt.store status = 'planned' and
    lod.scheduled date is null THEN
    NVL2(lod.actual date,
    cast(lod.actual date AS nvarchar2(30)),
    'N/A')
    when pt.store status = 'planned' and
    lod.scheduled date < CURRENT_DATE THEN
    NVL2(lod.actual date,
    cast(lod.actual date AS nvarchar2(30)),
    'Null')
    when pt.store status = 'planned' and
    lod.scheduled date >= CURRENT_DATE THEN
    NVL2(lod.actual date,
    cast(lod.actual date AS nvarchar2(30)),
    'N/A')
    end as DER_lod_ACT
    from
    product table pt,
    event table pr,
    event table pl,
    event table ps,
    event table fo,
    event table fb,
    event table fod,
    event table lo,
    event table lom,
    event table lod
    where
    pt.product code = pr.product code
    and pt.store code = pr.store code
    and pt.product code = pl.product code
    and pt.store code = pl.store code
    and pt.product code = fo.product code
    and pt.store code = fo.store code
    and pt.product code = fb.product code
    and pt.store code = fb.store code
    and pt.product code = fod.product code
    and pt.store code = fod.store code
    and pt.product code = lo.product code
    and pt.store code = lo.store code
    and pt.product code = lom.product code
    and pt.store code = lom.store code
    and pt.product code = lod.product code
    and pt.store code = lod.store code
    and pr.product code=pl.product code
    and pl.store code=ps.store code
    and ps.product code=fo.product code
    and fo.store code=fb.store code
    and fb.product code=fod.product code
    and fod.store code=lo.store code
    and lo.product code=lom.product code
    and lom.store code=lod.store code
    and pr.event code=1001
    and pl.event code=1002
    and ps.event code=1003
    and fo.event code=1004
    and fb.event code=1005
    and fod.event code=1006
    and lo.event code=1007
    and lom.event code=1008
    and lod.event code=1009
    order by product code,store code;
    THANKS IN ADVANCE FOR SPARING YOUR TIME IN UNDERSTANDING MY PROVLEM....
    REGARDS,
    MYTHRI.

    986300 wrote:
    from
    product table pt,
    event table pr,
    event table pl,
    event table ps,
    event table fo,
    event table fb,
    event table fod,
    event table lo,
    event table lom,
    event table lodabove is NOT valid SQL syntax

  • Dump for a select query

    Hi Gurus,
    I have a select query as follows:
        SELECT
                   vbap~vbeln
                   vbap~posnr
                   vbap~matnr
                   vbap~arktx
                   vbap~pstyv
                   vbap~abgru
                   vbap~prodh
                   vbap~netwr
                   vbap~werks
                   vbap~kwmeng
                   vbap~prctr
                   vbap~ps_psp_pnr
                               FROM vbap
                INTO TABLE i_item_vbap
                FOR ALL ENTRIES IN i_reg_vbak
                WHERE
                vbap~vbeln EQ i_reg_vbak-vbeln AND
                vbap~matnr IN s_matnr          AND
                vbap~werks IN s_werks          .
    However, when I execute the program, I get the dump saying as:
    I get this exception "DBIF_RSQL_INVALID_RSQL", assigned to CLASS  "CX_SY_OPEN_SQL_DB"
    Please help me in understanding this.
    Also, there are only 85 entries in i_reg_vbak, plus not many values are there for s_matnr and s_werks.
    I tried executing this query w/o for all entries, but still it gave a dump.
    Waiting for your reply, thanks!

    hello
    SELECT
    vbap~vbeln
    vbap~posnr
    vbap~matnr
    vbap~arktx
    vbap~pstyv
    vbap~abgru
    vbap~prodh
    vbap~netwr
    vbap~werks
    vbap~kwmeng
    vbap~prctr
    vbap~ps_psp_pnr
    from vbap into corresponding fields of table it_vbap.
    if u use any  fields of vbap on selection scrren then mention as
    eg: where vbeln in s_vbeln etc.
    with regards,
    sumanth reddy

  • How can replace IF condition for a Select query in my reports?

    IF s_bukrs-LOW = '4312' OR s_bukrs-LOW = '4313' OR s_bukrs-LOW = '4349'  .
    ELSEIF s_bukrs-LOW = '4310' OR s_bukrs-LOW = '4311' OR s_bukrs-LOW = '4587'.
    ENDIF.
    What if I want to use select query in place of IF condition, in my report for a Z -table in which I have made entries of ZZUSEREXIT-my progam name ,VAR1-4310,VAR2-4311,VAR3-4312,VAR4-4313,VAR5-4349,VAR6-4587?

    HI
    U can do this by two ways-
    (1) Using Two SELECT statementsie. one for IF statements and second for ELSEIF statements.
    Like--
        SELECT < field name>,
    WHERE s_bukrs-LOW = '4312' OR s_bukrs-LOW = '4313' OR s_bukrs-LOW = '4349' 
    SELECT < field name>,
    WHERE s_bukrs-LOW = '4310' OR s_bukrs-LOW = '4311' OR s_bukrs-LOW = '4587'.
    (2) U can do this in using IF with select statements.
    This will help u

  • How to reduce logical count and scan count for a select query

    hi,
    I have two tables one is master and other is history. i need to combine this two tables into one temporary table.
    I am using the below query to create temp table.
    Select * into temporders
    from
    (select * from orders
    union
    select * from ordershistory) b
    where updateon= (select max(updateon)from (select updateon,name,units,subunits from orders
    union
    select updateon,name,units,subunits from ordershistory) a
    where updateon <='11/08/2008 11:18 AM' and a.name=b.name and a.units=b.units and a.subunits=b.subunits group by name,units,subunits)
    order by report,subunitsorder
    the statistics for this query:
    SQL Server parse and compile time:
    CPU time = 47 ms, elapsed time = 62 ms.
    Table 'Worktable'. Scan count 556, logical reads 1569, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
    Table 'ORDERSHISTORY'. Scan count 116, logical reads 339, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
    Table 'ORDERS'. Scan count 116, logical reads 285, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
    SQL Server Execution Times:
    CPU time = 32 ms, elapsed time = 63 ms.
    (115 row(s) affected)
    you see logical reads and scan count for worktable(temporary) is quite high.
    So anyone can give a solution for reduce the scan count and logical reads.
    NOTE: name,units, subunits,updateon columns have primarykey

    SQL ServerAm i reading it properly? :(
    This is Oracle Forum And not the SQL Server.
    Regards.
    Satyaki De.

  • Need help with union of two selects

    select 1 selects items for a timespan.
    But if there is nothing found at one date,
    the date is not returned so I want a union with a calendar table
    Both selects work but how to make the union?
    Thanks for any help!
    select 1:
    SELECT COUNT(*) COUNT,
    fb_operation prodstep,
    kalenderwoche datum
    FROM stoerung,
    kalender
    WHERE str_kommenzeit > to_date('13.06.2006', 'dd.mm.yyyy')
    AND str_kommenzeit < to_date('11.07.2006', 'dd.mm.yyyy')
    AND to_char(str_kommenzeit,'dd.mm.yyyy') = to_char(fulldate,'dd.mm.yyyy')
    GROUP BY fb_operation,
    kalenderwoche
    ORDER BY fb_operation,
    kalenderwoche
    select 2:
    SELECT kalenderwoche datum
    from kalender
    WHERE fulldate > to_date('13.06.2006', 'dd.mm.yyyy')
    AND fulldate < to_date('11.07.2006', 'dd.mm.yyyy')

    THANKS A LOT!
    I tested it and it gave me good results
    the problem I still have is that then I expand the Date to
    to_date('11.12.2006') I just get the weeks
    that contain data. But I need all weeks that are selected, if there is
    no data the other fields shall be null or 0.
    This is much too difficult for me perhaps you can also help me with this!
    select * from
    (SELECT COUNT(*) COUNT,
    fb_operation prodstep,
    kalenderwoche datum
    FROM stoerung,
    kalender
    WHERE str_kommenzeit > to_date('13.06.2006', 'dd.mm.yyyy')
    AND str_kommenzeit < to_date('11.12.2006', 'dd.mm.yyyy')
    AND to_char(str_kommenzeit,'dd.mm.yyyy') = to_char(fulldate,'dd.mm.yyyy')
    GROUP BY fb_operation,
    kalenderwoche
    ORDER BY fb_operation,
    kalenderwoche) A,
    (SELECT kalenderwoche datum
    from kalender
    WHERE fulldate > to_date('13.06.2006', 'dd.mm.yyyy')
    AND fulldate < to_date('11.12.2006', 'dd.mm.yyyy') ) B
    where A.datum = B.datum (+)

  • HOW DO YOU GUYS DEAL WITH APPLE.. SO CONFUSING...NEED HELP WITH SPECS FOR PURCHASE OF IMAC 21.5

    Hi guys, been reading your forums, blogposts, etc and am getting more confused.  I'm just a video girl trying to produce meaningful content through web videos for small to mid sized businesses and want to come over from the dark side. 
    Good news,, I dont need a super giant system,  I do simple editing for web videos, minimal graphics, no motion graphics, no animation etc. currently using CS4, will probably end up with 5.5.
    I want to get imac 21.5 or 27 if i have to..  So here's the question we all have,,, what do I really need besides an Apple fairy godmother to figure this crazy stuff out?????
    I want to be able to have firewire add on, but the rest is what I need help with.   So i've been looking at cs6 specs, even though im not there yet, eventually will be,, so just need to run cs4 now and build from there.  I also want to eventually move to final cut down the road so I want imac able to upgrade to final cut.
    WHAT DO I REALLY NEED MINIMALLY FOR NOW?  WHAT CAN I GET LATER IF i CHOOSE TO DO MORE AND NEED MORE POWER?
    cs6:
    Multicore Intel processor with 64-bit support
    Mac OS X v10.6.8, v10.7, or v10.8**
    4GB of RAM (8GB recommended)
    4GB of available hard-disk space for installation; additional free space required during installation (cannot install on a volume that uses a case-sensitive file system or on removable flash storage devices)
    Additional disk space required for preview files and other working files (10GB recommended)
    1280x900 display
    7200 RPM hard drive (multiple fast disk drives, preferably RAID 0 configured, recommended)
    OpenGL 2.0–capable system
    DVD-ROM drive compatible with dual-layer DVDs (SuperDrive for burning DVDs; Blu-ray burner for creating Blu-ray Disc media)
    QuickTime 7.6.6 software required for QuickTime features
    Optional: Adobe-certified GPU card for GPU-accelerated performance
    Any responses would be great.  I know you guys are busy answering the really high end tech questions

    All the current iMac models (both 21.5" and 27" with OS X Mt. Lion 10.8) will run CS4, 5.5 and 6 just fine.  They will also run Final Cut Pro X just fine.  Ditto for most any application you may want to use.
    Below are some notes (specific to your apparent requirements) that may help you with your purchase decision:
    Notes on purchasing a 21.5" iMac
    All 21.5" iMacs come with 8GB RAM but you cannot add more later.  I strongly suggest getting the maximum RAM (16GB) when you order the iMac.
    The basic hard drive is a 1TB 5400rpm drive.  It will work fine with Adobe CS but you will probably want the added speed of the optional 1TB Fusion drive for better performance. Some people will recommend/argue for one of the optional SSD drives instead, but they are very expensive and still only come in relatively small capacities - I don't recommend the SSD drives.  Get the Fusion drive and spend any extra money on a good external hard drive for backup and/or extra storage instead of an SSD.
    Notes on purchasing a 27" iMac
    All 27" iMacs come with 8GB RAM and you can add more later, up to 32GB
    The basic hard drive is a 1TB 7200rpm drive - it will be fine with Adobe CS.  There are upgrade options to a 3TB 7200rpm drive or a 1TB or 3TB fusion drive - these will be fine also.  There are also SSD drive options, but I do not recommend them. (Same comments as above.)
    Notes on all the current iMacs
    iMacs no longer come with built-in CD/DVD drives.  If you need one, you will need to purchase the Apple Superdrive accessory drive ($79)
    All of the iMac graphic processors (GPU's) are compatible with Adobe CS 4, 5.5, 6
    It is very difficult to impossible to change or upgrade the hard drive later on, so don't buy low-end thinking you can add a better internal hard drive later.
    Be aware that Macs always come with the latest (most recent) version of OS X.  And OS X Mavericks (10.9) is due to be released soon (in the next month or two).  There is no guarantee that the older Adobe CS 4 or 5.5 versions will run on OS X Mavericks.  If you cannot upgrade to CS 6 in the near future, you may want to purchase now rather than after OS X Mavericks is released.
    For what it's worth, I'd recommend the 27" iMac if your budget can afford it.  You will appreciate the larger screen size and added capabilities over the years you will use the computer.

Maybe you are looking for