Oracle query taking gtime

Hi All,
Could any one guide to resolve the query tuign issue please.
I habe used explain plan for this.
And reduced the cpu cost .But still not effective.
My data base version is oracle 10.2.0.3.0 - 64bi
select distinct
o509970."Invoice",
o509970."Invoice Date",
o509970."Customer",
o509970."Customer #",
o509970."Customer Purchase Order",
o509970."Ship To Address1", o509970."Ship To Address2",
o509970."Ship To City", o509970."Ship To State",
o509970."Ship To Zip Code",
o509970."Bill To Address1", o509970."Bill To Address2",
o509970."Bill To City",o509970."Bill To State",
o509970."Bill To Zip Code",
o509970."Item Number",
o509970."Item Description",
o509970."Line Amount",
o509970."Line Type",
o509970."Tax Amount",
--o509970."Freight",
o509970."Exempt Amount",
o509970."Taxable Amount",
o509970."Invoice Total"
from (
select --tax_adjusted "Tax",
party_name "Customer",
account_number "Customer #",
purchase_order "Customer Purchase Order",
trx_number "Invoice",
trx_date "Invoice Date",
invoice_currency_code "Currency",
exchange_rate "Exchange Rate",
address1 "Ship To Address1",
address2 "Ship To Address2",
city "Ship To City",
state "Ship To State",
postal_code "Ship To Zip Code",
address1_bill_to "Bill To Address1",
address2_bill_to "Bill To Address2",
city_bill_to "Bill To City",
state_bill_to "Bill To State",
postal_code_bill_to "Bill To Zip Code",
inventory_item_id "Item Number",
description "Item Description",
extended_amount "Line Amount" ,
line_type "Line Type",
--freight_adjusted "Freight",
taxable_amount "Taxabale Amount",
select sum(rctl.extended_amount)
from ar.ra_customer_trx_lines_all rctl
where rctl.line_type = 'TAX'
and rctl.customer_trx_id = a.customer_trx_id
) "Tax Amount"
,nvl(extended_amount - taxable_amount,0) "Exempt Amount"
,taxable_amount "Taxable Amount",
select sum(nvl(rctl.extended_amount,0)) invoice_amt
from ar.ra_customer_trx_lines_all rctl
where rctl.customer_trx_id = a.customer_trx_id
) "Invoice Total"
from
select distinct --aa.tax_adjusted ,
hp.party_name ,
hca.account_number,
ct.purchase_order ,
ct.trx_number,
ct.trx_date ,
ct.invoice_currency_code ,
ct.exchange_rate ,
hl.address1 ,
hl.address2 ,
hl.city ,
hl.state ,
hl.postal_code ,
hba.address1 address1_bill_to ,
hba.address2 address2_bill_to ,
hba.city city_bill_to ,
hba.state state_bill_to ,
hba.postal_code postal_code_bill_to,
cta.inventory_item_id ,
cta.description,
cta.line_type,
cta.taxable_amount,
nvl(cta.extended_amount-cta.taxable_amount,0),
--freight_adjusted,
cta.extended_amount ,
cta.customer_trx_id
from
ar.ra_cust_trx_line_gl_dist_all aa, ar.ar_receivables_trx_all rt, ar.ra_customer_trx_all ct, ar.ra_cust_trx_types_all rta,
ar.ra_customer_trx_lines_all cta
,ar.hz_parties hp
,ar.hz_cust_accounts hca
,ar.hz_party_sites hps
,ar.hz_cust_acct_sites_all hcas
,ar.hz_cust_site_uses_all hcsu
,ar.hz_locations hl
,ar.ra_cust_trx_types_all rctta
,(select hl.address1, hl.address2,hl.city, hl.state,
hl.postal_code, hcsu.site_use_id, hca.cust_account_id
from ar.hz_parties hp
,ar.hz_cust_accounts hca
,ar.hz_party_sites hps
,ar.hz_cust_acct_sites_all hcas
,ar.hz_cust_site_uses_all hcsu
,ar.hz_locations hl
where 1=1
and hcas.cust_acct_site_id = hcsu.cust_acct_site_id
and hps.party_site_id = hcas.party_site_id
and hp.party_id = hps.party_id
and hp.party_id = hca.party_id
and hcas.cust_account_id = hca.cust_account_id
and hps.location_id = hl.location_id
and hcsu.site_use_code = 'BILL_TO') hba
where 1=1
--and aa.RECEIVABLES_TRX_ID = rt.RECEIVABLES_TRX_ID    
and aa.customer_trx_id = ct.customer_trx_id
and
aa.customer_trx_line_id = cta.customer_trx_line_id
and ct.customer_trx_id = cta.customer_trx_id
and ct.ship_to_site_use_id = hcsu.site_use_id
and rt.org_id = ct.org_id--sanju
and rt.org_id=118
and hcas.cust_acct_site_id = hcsu.cust_acct_site_id
and hps.party_site_id = hcas.party_site_id
and hp.party_id = hps.party_id
and hp.party_id = hca.party_id
and hcas.cust_account_id = hca.cust_account_id
and hps.location_id = hl.location_id
and ct.bill_to_customer_id = hba.cust_account_id
and ct.bill_to_site_use_id = hba.site_use_id
and ct.cust_trx_type_id = rta.cust_trx_type_id
and rta.type in ('INV','CM')
and aa.gl_date >= to_date('30-SEP-2012', 'DD-MON-YYYY')
and aa.gl_date <= to_date('29-DEC-2012', 'DD-MON-YYYY')
and aa.set_of_books_id = 1001
and hl.state='CA'
--and ct.trx_number='12969636'
group by --aa.apply_date, aa.gl_date,    
--aa.adjustment_number, aa.line_adjusted,    
freight_adjusted, aa.tax_adjusted,
--aa.type,
rt.name, --aa.reason_code,
hl.state ,
hp.party_name, hca.account_number,
ct.trx_number, ct.trx_date,
ct.invoice_currency_code, ct.exchange_rate,
hl.address1, hl.address2,
hl.city, hl.state,
hl.postal_code,
hba.address1, hba.address2,
hba.city, hba.state,
hba.postal_code, cta.inventory_item_id,cta.description, cta.line_type, cta.unit_standard_price ,
cta.extended_amount, cta.quantity_invoiced,ct.purchase_order
,cta.customer_trx_id,cta.taxable_amount
UNION ALL
select distinct /*+ RULE */ --aa.tax_adjusted "Tax",   
hp.party_name "Customer", hca.account_number "Customer #",ct.purchase_order "Customer Purchase Order",
ct.trx_number "Invoice", ct.trx_date "Invoice Date",
ct.invoice_currency_code "Currency", ct.exchange_rate "Exchange Rate",
hl.address1 "Ship To Address1", hl.address2 "Ship To Address2",
hl.city "Ship To City", hl.state "Ship To State",
hl.postal_code "Ship To Zip Code",
hba.address1 "Bill To Address1", hba.address2 "Bill To Address2",
hba.city "Bill To City", hba.state "Bill To State",
hba.postal_code "Bill To Zip Code", cta.inventory_item_id "Item Number", cta.description "Item Description",
cta.line_type "Line Type",--freight_adjusted "Freight",
cta.unit_standard_price "Line Amount" ,cta.customer_trx_id,
nvl(cta.extended_amount-cta.taxable_amount,0) "Exempt Amount"
,cta.taxable_amount "Taxable Amount"
from ar.ra_cust_trx_line_gl_dist_all aa, ar.ar_receivables_trx_all rt, ar.ra_customer_trx_all ct,ar.ra_cust_trx_types_all rta,
ar.ra_customer_trx_lines_all cta
,ar.hz_parties hp
,ar.hz_cust_accounts hca
,ar.hz_party_sites hps
,ar.hz_cust_acct_sites_all hcas
,ar.hz_cust_site_uses_all hcsu
,ar.hz_locations hl
,ar.ra_cust_trx_types_all rctta
,(select hl.address1, hl.address2,hl.city, hl.state,
hl.postal_code, hcsu.site_use_id, hca.cust_account_id
from ar.hz_parties hp
,ar.hz_cust_accounts hca
,ar.hz_party_sites hps
,ar.hz_cust_acct_sites_all hcas
,ar.hz_cust_site_uses_all hcsu
,ar.hz_locations hl
where hcas.cust_acct_site_id = hcsu.cust_acct_site_id
and hps.party_site_id = hcas.party_site_id
and hp.party_id = hps.party_id
and hp.party_id = hca.party_id
and hcas.cust_account_id = hca.cust_account_id
and hps.location_id = hl.location_id
and hcsu.site_use_code = 'BILL_TO') hba
where --aa.RECEIVABLES_TRX_ID = rt.RECEIVABLES_TRX_ID    
aa.customer_trx_id = ct.customer_trx_id
and
aa.customer_trx_line_id = cta.customer_trx_line_id
and ct.customer_trx_id = cta.customer_trx_id
and ct.bill_to_site_use_id = hcsu.site_use_id
and ct.ship_to_site_use_id is null
and hcas.cust_acct_site_id = hcsu.cust_acct_site_id
and hps.party_site_id = hcas.party_site_id
and hp.party_id = hps.party_id
and hp.party_id = hca.party_id
and hcas.cust_account_id = hca.cust_account_id
and hps.location_id = hl.location_id
and ct.bill_to_customer_id = hba.cust_account_id
and ct.bill_to_site_use_id = hba.site_use_id
and aa.gl_date >= to_date('30-SEP-2012', 'DD-MON-YYYY')
and aa.gl_date <= to_date('29-DEC-2012', 'DD-MON-YYYY')
and ct.cust_trx_type_id = rta.cust_trx_type_id
and rta.type in ('INV','CM')
and aa.set_of_books_id = 1001
and hl.state='CA'
and rt.org_id = ct.org_id--sanju
and rt.org_id=118
--and ct.trx_number='12969636'
group by --aa.apply_date, aa.gl_date, aa.adjustment_number, aa.line_adjusted,    
--freight_adjusted, aa.tax_adjusted,    
--aa.type,
rt.name, --aa.reason_code,
hl.state ,
hp.party_name, hca.account_number,
ct.trx_number, ct.trx_date,
ct.invoice_currency_code, ct.exchange_rate,
hl.address1, hl.address2,
hl.city, hl.state,
hl.postal_code,
hba.address1, hba.address2,
hba.city, hba.state,
hba.postal_code , cta.inventory_item_id, cta.description, cta.unit_standard_price ,cta.extended_amount ,cta.quantity_invoiced,ct.purchase_order
,cta.customer_trx_id,cta.line_type,cta.taxable_amount
)a
)o509970
--order by o509970."Invoice"
Thanks & Regards

Seriously? 308 post and you still don't put formatted code and you don't use {noformat}{noformat} tag.
I would suggest you to take some time and read the two FAQ thread.
{message:id=9360002}
{message:id=9360003}
And why is that most of your question dont get answered?Handle : user651567
Status Level : Newbie
Registered : Aug 11, 2008
Total Posts : 308
Total Questions: 160 (153 unresolved)

Similar Messages

  • Oracle query taking more time in SSRS

    Hi All
    we have report which connects to Orale DB . the Query for the datset is running in 9 Secs  in PL/sql developer  but the same query is taking more than 150 secs in SSRS. we are using Oracleclient type provider.
    Surendra Thota

    Hi Surendra,
    Based on the current description, I understand that you may use Oracle Provider for OLE DB to connect Oracle database. If so, I suggest you using Microsoft OLE DB Provider for Oracle to compare the query time between SQLPlus and SSRS.
    Here is a relative thread (SSRS Report with Oracle database performance problems) for your reference.
    Hope this helps.
    Regards,
    Heidi Duan
    If you have any feedback on our support, please click
    here.
    Heidi Duan
    TechNet Community Support

  • Oracle - Query taking too long (Materialized view)

    Hi,
    I am extracting billing informaiton and storing in 3 different tables... in order to show total billing (80 to 90 columns, 1 million rows per month), I've used a materialized view... I do not have indexes on 3 billing tables - do have 3 indexes on Materialized view...
    at the moment it's taking too long to query the data (running a query via toad fails and shows "Out of Memory" error message; runing a query via APEX though is providing results but taking way too long)...
    Please advice how to make the query efficient...

    tparvaiz,
    Is it possible when building your materialized view to summarize and consolidate the data?
    Out of a million rows, what would your typical user do with that amount data if they could retrieve it readily? The answer to this question may indicate if and how to summarize the data within the materialized view.
    Jeff
    Edited by: jwellsnh on Mar 25, 2010 7:02 AM

  • Query taking so long to execute.

    I have one table with 211 rows, When i am executing Delete from TEHSIL_TBL; its taking too long time to delete 211 rows. I execute explain plan then i am getting the following results.
    SQL> explain plan for delete from TEHSIL_TBL;
    Explained.
    SQL> @C:\oracle\product\10.2.0\db_1\RDBMS\ADMIN\utlxpls.sql
    PLAN_TABLE_OUTPUT
    Plan hash value: 3350021484
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | DELETE STATEMENT | | 205 | 1435 | 1 (0)| 00:00:01 |
    | 1 | DELETE | TEHSIL_TBL | | | | |
    | 2 | INDEX FULL SCAN| PK_TEH_ID | 205 | 1435 | 1 (0)| 00:00:01 |
    Please suggest why that query taking so long tome to execute.
    Thanks in Advance...
    Asmit

    966523 wrote:
    I have one table with 211 rows, When i am executing Delete from TEHSIL_TBL; its taking too long time to delete 211 rows. I execute explain plan then i am getting the following results.
    SQL> explain plan for delete from TEHSIL_TBL;
    Explained.
    SQL> @C:\oracle\product\10.2.0\db_1\RDBMS\ADMIN\utlxpls.sql
    PLAN_TABLE_OUTPUT
    Plan hash value: 3350021484
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | DELETE STATEMENT | | 205 | 1435 | 1 (0)| 00:00:01 |
    | 1 | DELETE | TEHSIL_TBL | | | | |
    | 2 | INDEX FULL SCAN| PK_TEH_ID | 205 | 1435 | 1 (0)| 00:00:01 |
    Please suggest why that query taking so long tome to execute.Please quantify "long time".
    >
    >
    Thanks in Advance...
    AsmitEXPLAIN PLAN shows time of 1 SECOND!
    How must faster should it be?

  • Query taking long time for EXTRACTING the data more than 24 hours

    Hi ,
    Query taking long time for EXTRACTING the data more than 24 hours please find the query and explain plan details below even indexes avilable on table's goe's to FULL TABLE SCAN. please suggest me.......
    SQL> explain plan for select a.account_id,round(a.account_balance,2) account_balance,
    2 nvl(ah.invoice_id,ah.adjustment_id) transaction_id,
    to_char(ah.effective_start_date,'DD-MON-YYYY') transaction_date,
    to_char(nvl(i.payment_due_date,
    to_date('30-12-9999','dd-mm-yyyy')),'DD-MON-YYYY')
    due_date, ah.current_balance-ah.previous_balance amount,
    decode(ah.invoice_id,null,'A','I') transaction_type
    3 4 5 6 7 8 from account a,account_history ah,invoice i_+
    where a.account_id=ah.account_id
    and a.account_type_id=1000002
    and round(a.account_balance,2) > 0
    and (ah.invoice_id is not null or ah.adjustment_id is not null)
    and ah.CURRENT_BALANCE > ah.previous_balance
    and ah.invoice_id=i.invoice_id(+)
    AND a.account_balance > 0
    order by a.account_id,ah.effective_start_date desc; 9 10 11 12 13 14 15 16
    Explained.
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    | Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)|
    | 0 | SELECT STATEMENT | | 544K| 30M| | 693K (20)|
    | 1 | SORT ORDER BY | | 544K| 30M| 75M| 693K (20)|
    |* 2 | HASH JOIN | | 544K| 30M| | 689K (20)|
    |* 3 | TABLE ACCESS FULL | ACCOUNT | 20080 | 294K| | 6220 (18)|
    |* 4 | HASH JOIN OUTER | | 131M| 5532M| 5155M| 678K (20)|
    |* 5 | TABLE ACCESS FULL| ACCOUNT_HISTORY | 131M| 3646M| | 197K (25)|
    | 6 | TABLE ACCESS FULL| INVOICE | 262M| 3758M| | 306K (18)|
    Predicate Information (identified by operation id):
    2 - access("A"."ACCOUNT_ID"="AH"."ACCOUNT_ID")
    3 - filter("A"."ACCOUNT_TYPE_ID"=1000002 AND "A"."ACCOUNT_BALANCE">0 AND
    ROUND("A"."ACCOUNT_BALANCE",2)>0)
    4 - access("AH"."INVOICE_ID"="I"."INVOICE_ID"(+))
    5 - filter("AH"."CURRENT_BALANCE">"AH"."PREVIOUS_BALANCE" AND ("AH"."INVOICE_ID"
    IS NOT NULL OR "AH"."ADJUSTMENT_ID" IS NOT NULL))
    22 rows selected.
    Index Details:+_
    SQL> select INDEX_OWNER,INDEX_NAME,COLUMN_NAME,TABLE_NAME from dba_ind_columns where
    2 table_name in ('INVOICE','ACCOUNT','ACCOUNT_HISTORY') order by 4;
    INDEX_OWNER INDEX_NAME COLUMN_NAME TABLE_NAME
    OPS$SVM_SRV4 P_ACCOUNT ACCOUNT_ID ACCOUNT
    OPS$SVM_SRV4 U_ACCOUNT_NAME ACCOUNT_NAME ACCOUNT
    OPS$SVM_SRV4 U_ACCOUNT CUSTOMER_NODE_ID ACCOUNT
    OPS$SVM_SRV4 U_ACCOUNT ACCOUNT_TYPE_ID ACCOUNT
    OPS$SVM_SRV4 I_ACCOUNT_ACCOUNT_TYPE ACCOUNT_TYPE_ID ACCOUNT
    OPS$SVM_SRV4 I_ACCOUNT_INVOICE INVOICE_ID ACCOUNT
    OPS$SVM_SRV4 I_ACCOUNT_PREVIOUS_INVOICE PREVIOUS_INVOICE_ID ACCOUNT
    OPS$SVM_SRV4 U_ACCOUNT_NAME_ID ACCOUNT_NAME ACCOUNT
    OPS$SVM_SRV4 U_ACCOUNT_NAME_ID ACCOUNT_ID ACCOUNT
    OPS$SVM_SRV4 I_LAST_MODIFIED_ACCOUNT LAST_MODIFIED ACCOUNT
    OPS$SVM_SRV4 I_ACCOUNT_INVOICE_ACCOUNT INVOICE_ACCOUNT_ID ACCOUNT
    OPS$SVM_SRV4 I_ACCOUNT_HISTORY_ACCOUNT ACCOUNT_ID ACCOUNT_HISTORY
    OPS$SVM_SRV4 I_ACCOUNT_HISTORY_ACCOUNT SEQNR ACCOUNT_HISTORY
    OPS$SVM_SRV4 I_ACCOUNT_HISTORY_INVOICE INVOICE_ID ACCOUNT_HISTORY
    OPS$SVM_SRV4 I_ACCOUNT_HISTORY_ADINV INVOICE_ID ACCOUNT_HISTORY
    OPS$SVM_SRV4 I_ACCOUNT_HISTORY_CIA CURRENT_BALANCE ACCOUNT_HISTORY
    OPS$SVM_SRV4 I_ACCOUNT_HISTORY_CIA INVOICE_ID ACCOUNT_HISTORY
    OPS$SVM_SRV4 I_ACCOUNT_HISTORY_CIA ADJUSTMENT_ID ACCOUNT_HISTORY
    OPS$SVM_SRV4 I_ACCOUNT_HISTORY_CIA ACCOUNT_ID ACCOUNT_HISTORY
    OPS$SVM_SRV4 I_ACCOUNT_HISTORY_LMOD LAST_MODIFIED ACCOUNT_HISTORY
    OPS$SVM_SRV4 I_ACCOUNT_HISTORY_ADINV ADJUSTMENT_ID ACCOUNT_HISTORY
    OPS$SVM_SRV4 I_ACCOUNT_HISTORY_PAYMENT PAYMENT_ID ACCOUNT_HISTORY
    OPS$SVM_SRV4 I_ACCOUNT_HISTORY_ADJUSTMENT ADJUSTMENT_ID ACCOUNT_HISTORY
    OPS$SVM_SRV4 I_ACCOUNT_HISTORY_APPLIED_DT APPLIED_DATE ACCOUNT_HISTORY
    OPS$SVM_SRV4 P_INVOICE INVOICE_ID INVOICE
    OPS$SVM_SRV4 U_INVOICE CUSTOMER_INVOICE_STR INVOICE
    OPS$SVM_SRV4 I_LAST_MODIFIED_INVOICE LAST_MODIFIED INVOICE
    OPS$SVM_SRV4 U_INVOICE_ACCOUNT ACCOUNT_ID INVOICE
    OPS$SVM_SRV4 U_INVOICE_ACCOUNT BILL_RUN_ID INVOICE
    OPS$SVM_SRV4 I_INVOICE_BILL_RUN BILL_RUN_ID INVOICE
    OPS$SVM_SRV4 I_INVOICE_INVOICE_TYPE INVOICE_TYPE_ID INVOICE
    OPS$SVM_SRV4 I_INVOICE_CUSTOMER_NODE CUSTOMER_NODE_ID INVOICE
    32 rows selected.
    Regards,
    Bathula
    Oracle-DBA

    I have some suggestions. But first, you realize that you have some redundant indexes, right? You have an index on account(account_name) and also account(account_name, account_id), and also account_history(invoice_id) and account_history(invoice_id, adjustment_id). No matter, I will suggest some new composite indexes.
    Also, you do not need two lines for these conditions:
    and round(a.account_balance, 2) > 0
    AND a.account_balance > 0
    You can just use: and a.account_balance >= 0.005
    So the formatted query isselect a.account_id,
           round(a.account_balance, 2) account_balance,
           nvl(ah.invoice_id, ah.adjustment_id) transaction_id,
           to_char(ah.effective_start_date, 'DD-MON-YYYY') transaction_date,
           to_char(nvl(i.payment_due_date, to_date('30-12-9999', 'dd-mm-yyyy')),
                   'DD-MON-YYYY') due_date,
           ah.current_balance - ah.previous_balance amount,
           decode(ah.invoice_id, null, 'A', 'I') transaction_type
      from account a, account_history ah, invoice i
    where a.account_id = ah.account_id
       and a.account_type_id = 1000002
       and (ah.invoice_id is not null or ah.adjustment_id is not null)
       and ah.CURRENT_BALANCE > ah.previous_balance
       and ah.invoice_id = i.invoice_id(+)
       AND a.account_balance >= .005
    order by a.account_id, ah.effective_start_date desc;You will probably want to select:
    1. From ACCOUNT first (your smaller table), for which you supply a literal on account_type_id. That should limit the accounts retrieved from ACCOUNT_HISTORY
    2. From ACCOUNT_HISTORY. We want to limit the records as much as possible on this table because of the outer join.
    3. INVOICE we want to access last because it seems to be least restricted, it is the biggest, and it has the outer join condition so it will manufacture rows to match as many rows as come back from account_history.
    Try the query above after creating the following composite indexes. The order of the columns is important:create index account_composite_i on account(account_type_id, account_balance, account_id);
    create index acct_history_comp_i on account_history(account_id, invoice_id, adjustment_id, current_balance, previous_balance, effective_start_date);
    create index invoice_composite_i on invoice(invoice_id, payment_due_date);All the columns used in the where clause will be indexed, in a logical order suited to the needs of the query. Plus each selected column is indexed as well so that we should not need to touch the tables at all to satisfy the query.
    Try the query after creating these indexes.
    A final suggestion is to try larger sort and hash area sizes and a manual workarea policy.alter session set workarea_size_policy = manual;
    alter session set sort_area_size = 2147483647;
    alter session set hash_area_size = 2147483647;

  • Query taking much time Orace 9i

    Hi,
    **How can we tune the sql query in oracle 9i.**
    The select query taking more than 1 and 30 min to throw the result.
    Due to this,
    We have created materialsed view on the select query and also we submitted a job to get Materilazed view refreshed daily in dba_jobs.
    When we tried to retrive the data from Materilased view getting result very quickly.
    But the job which we has been assisgned in Dbajobs taking equal  time to complete, as the query use to take.
    We feel since the job taking much time in the test Database and it may cause load if we move the same scripts in Production Environment.
    Please suggest how to resolvethe issue and also how to tune the sql
    With Regards,
    Srinivas
    Edited by: Srinivas.. on Dec 17, 2009 6:29 AM

    Hi Srinivas;
    Please follow this search and see its helpful
    Regard
    Helios

  • Sql Query taking very long time to complete

    Hi All,
    DB:oracle 9i R2
    OS:sun solaris 8
    Below is the Sql Query taking very long time to complete
    Could any one help me out regarding this.
    SELECT MAX (md1.ID) ID, md1.request_id, md1.jlpp_transaction_id,
    md1.transaction_version
    FROM transaction_data_arc md1
    WHERE md1.transaction_name = :b2
    AND md1.transaction_type = 'REQUEST'
    AND md1.message_type_code = :b1
    AND NOT EXISTS (
    SELECT NULL
    FROM transaction_data_arc tdar2
    WHERE tdar2.request_id = md1.request_id
    AND tdar2.jlpp_transaction_id != md1.jlpp_transaction_id
    AND tdar2.ID > md1.ID)
    GROUP BY md1.request_id,
    md1.jlpp_transaction_id,
    md1.transaction_version
    Any alternate query to get the same results?
    kindly let me know if any one knows.
    regards,
    kk.
    Edited by: kk001 on Apr 27, 2011 11:23 AM

    Dear
    /* Formatted on 2011/04/27 08:32 (Formatter Plus v4.8.8) */
    SELECT   MAX (md1.ID) ID, md1.request_id, md1.jlpp_transaction_id,
             md1.transaction_version
        FROM transaction_data_arc md1
       WHERE md1.transaction_name = :b2
         AND md1.transaction_type = 'REQUEST'
         AND md1.message_type_code = :b1
         AND NOT EXISTS (
                SELECT NULL
                  FROM transaction_data_arc tdar2
                 WHERE tdar2.request_id = md1.request_id
                   AND tdar2.jlpp_transaction_id != md1.jlpp_transaction_id
                   AND tdar2.ID > md1.ID)
    GROUP BY md1.request_id
            ,md1.jlpp_transaction_id
            ,md1.transaction_versionCould you please post here :
    (a) the available indexes on transaction_data_arc table
    (b) the description of transaction_data_arc table
    (c) and the formatted explain plan you will get after executing the query and issuing:
    select * from table (dbms_xplan.display_cursor);Hope this helps
    Mohamed Houri

  • Query on using Variables in Oracle Query

    Hi
    i am new to Oracle, i have tried extracting data from the Oracle Database using the following Query which includes 1 variable SYSDATE_UTS, however when i try to execute the Query i get an error. Please let me know what am i doing wrong and how can i correct it.
    Error Message
    ORA-06550: line 4, column 1:
    PLS-00428: an INTO clause is expected in this SELECT statement
    Oracle Query
    DECLARE SYSDATE_UTS NUMBER := (sysdate-to_date('19700101','yyyymmdd'))*86400;
    BEGIN
    SELECT
    INCIDENT_NUMBER,
    to_date(to_char((1/86400*REPORTED_DATE)+to_date('19700101','yyyymmdd'),'mm/dd/yyyy hh24:mi:ss'),'mm/dd/yyyy hh24:mi:ss') as REPORTED_DATE_TIME,
    ,GROUP_TRANSFERS
    ,LAST_MODIFIED_BY
    ,to_date(to_char(to_date('01011970','ddmmyyyy')+1/24/60/60 * LAST_MODIFIED_DATE,'mm/dd/yyyy hh24:mi:ss'),'mm/dd/yyyy hh24:mi:ss') as LAST_MODIFIED_DATE
    ,(to_date(to_char(to_date('01011970','ddmmyyyy')+1/24/60/60 * SYSDATE_UTS,'mm/dd/yyyy'),'mm/dd/yyyy')) - (to_date(to_char(+to_date('19700101','yyyymmdd')+1/86400*REPORTED_DATE,'mm/dd/yyyy'),'mm/dd/yyyy')) as AGE
    ,CASE
    WHEN (to_date(to_char(to_date('01011970','ddmmyyyy')+1/24/60/60 * SYSDATE_UTS,'mm/dd/yyyy'),'mm/dd/yyyy')) - (to_date(to_char(+to_date('19700101','yyyymmdd')+1/86400*REPORTED_DATE,'mm/dd/yyyy'),'mm/dd/yyyy')) BETWEEN 0 AND 1 THEN '0-1 Days'
    WHEN (to_date(to_char(to_date('01011970','ddmmyyyy')+1/24/60/60 * SYSDATE_UTS, 'mm/dd/yyyy'),'mm/dd/yyyy')) - (to_date(to_char(+to_date('19700101','yyyymmdd')+1/86400*REPORTED_DATE,'mm/dd/yyyy'),'mm/dd/yyyy')) BETWEEN 2 AND 4 THEN '2-4 Days'
    WHEN (to_date(to_char(to_date('01011970','ddmmyyyy')+1/24/60/60 * SYSDATE_UTS,'mm/dd/yyyy'),'mm/dd/yyyy')) - (to_date(to_char(+to_date('19700101','yyyymmdd')+1/86400*REPORTED_DATE,'mm/dd/yyyy'),'mm/dd/yyyy')) BETWEEN 5 AND 9 THEN '5-9 Days'
    WHEN (to_date(to_char(to_date('01011970','ddmmyyyy')+1/24/60/60 * SYSDATE_UTS,'mm/dd/yyyy'),'mm/dd/yyyy')) - (to_date(to_char(+to_date('19700101','yyyymmdd')+1/86400*REPORTED_DATE,'mm/dd/yyyy'),'mm/dd/yyyy')) BETWEEN 10 AND 19 THEN '10-19 Days'
    WHEN (to_date(to_char(to_date('01011970','ddmmyyyy')+1/24/60/60 * SYSDATE_UTS,'mm/dd/yyyy'),'mm/dd/yyyy')) - (to_date(to_char(+to_date('19700101','yyyymmdd')+1/86400*REPORTED_DATE,'mm/dd/yyyy'),'mm/dd/yyyy')) >20 THEN '20+ Days'
    ELSE 'UNKNOWN'
    END AS AGE_GROUP
    FROM IncidentDataBase
    and STATUS not in (4,5,6)
    and rownum <10;
    END;

    Hi Frank
    i am using the following Oracle Version
    Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
    PL/SQL Release 10.2.0.5.0 - Production
    CORE     10.2.0.5.0     Production
    TNS for Linux: Version 10.2.0.5.0 - Production
    NLSRTL Version 10.2.0.5.0 - Production
    and Quest Toad for Oracle to write and execute the queries:
    Toad for Oracle Xpert
    Version 10.1.1.8
    The code i am using is:
    variable SYSDATE_UTS NUMBER;
    exec SYSDATE_UTS := (sysdate-to_date('19700101','yyyymmdd'))*86400;
    SELECT
    INCIDENT_NUMBER,
    to_date(to_char((1/86400*REPORTED_DATE)+to_date('19700101','yyyymmdd'),'mm/dd/yyyy hh24:mi:ss'),'mm/dd/yyyy hh24:mi:ss') as REPORTED_DATE_TIME
    ,GROUP_TRANSFERS
    ,LAST_MODIFIED_BY
    ,to_date(to_char(to_date('01011970','ddmmyyyy')+1/24/60/60 * LAST_MODIFIED_DATE,'mm/dd/yyyy hh24:mi:ss'),'mm/dd/yyyy hh24:mi:ss') as LAST_MODIFIED_DATE
    ,(to_date(to_char(to_date('01011970','ddmmyyyy')+1/24/60/60 * :SYSDATE_UTS,'mm/dd/yyyy'),'mm/dd/yyyy')) - (to_date(to_char(+to_date('19700101','yyyymmdd')+1/86400*REPORTED_DATE,'mm/dd/yyyy'),'mm/dd/yyyy')) as AGE
    ,CASE
    WHEN (to_date(to_char(to_date('01011970','ddmmyyyy')+1/24/60/60 * :SYSDATE_UTS,'mm/dd/yyyy'),'mm/dd/yyyy')) - (to_date(to_char(+to_date('19700101','yyyymmdd')+1/86400*REPORTED_DATE,'mm/dd/yyyy'),'mm/dd/yyyy')) BETWEEN 0 AND 1 THEN '0-1 Days'
    WHEN (to_date(to_char(to_date('01011970','ddmmyyyy')+1/24/60/60 * :SYSDATE_UTS, 'mm/dd/yyyy'),'mm/dd/yyyy')) - (to_date(to_char(+to_date('19700101','yyyymmdd')+1/86400*REPORTED_DATE,'mm/dd/yyyy'),'mm/dd/yyyy')) BETWEEN 2 AND 4 THEN '2-4 Days'
    WHEN (to_date(to_char(to_date('01011970','ddmmyyyy')+1/24/60/60 * :SYSDATE_UTS,'mm/dd/yyyy'),'mm/dd/yyyy')) - (to_date(to_char(+to_date('19700101','yyyymmdd')+1/86400*REPORTED_DATE,'mm/dd/yyyy'),'mm/dd/yyyy')) BETWEEN 5 AND 9 THEN '5-9 Days'
    WHEN (to_date(to_char(to_date('01011970','ddmmyyyy')+1/24/60/60 * :SYSDATE_UTS,'mm/dd/yyyy'),'mm/dd/yyyy')) - (to_date(to_char(+to_date('19700101','yyyymmdd')+1/86400*REPORTED_DATE,'mm/dd/yyyy'),'mm/dd/yyyy')) BETWEEN 10 AND 19 THEN '10-19 Days'
    WHEN (to_date(to_char(to_date('01011970','ddmmyyyy')+1/24/60/60 * :SYSDATE_UTS,'mm/dd/yyyy'),'mm/dd/yyyy')) - (to_date(to_char(+to_date('19700101','yyyymmdd')+1/86400*REPORTED_DATE,'mm/dd/yyyy'),'mm/dd/yyyy')) >20 THEN '20+ Days'
    ELSE 'UNKNOWN'
    END AS AGE_GROUP
    FROM IncidentDataBase
    WHERE STATUS not in (4,5,6)
    and rownum <10;
    Notes:
    1. When i put the cursor before "variable" (starting of the query) and execute the script i get an Error: ORA-00900: invalid SQL statement.
    2. When i put the cursor just before "SELECT" i get a pop up.
    a. it is a Toad window which displays the available variables (in this case :SYSDATE_UTS).
    b. gives me a dropdown option to select the type (by default VARCHAR2 is selected).
    c. there is a value field where i need to enter the value for the Variable.
    d. the SQL statement shown in this dilog box does not include the 1st 2 lines
    variable SYSDATE_UTS NUMBER;
    exec SYSDATE_UTS := (sysdate-to_date('19700101','yyyymmdd'))*86400;
    Q: is there something wrong in the syntax i am using?
    Sven W. - I have been using your method all these days, which works just fine. i wanted to know how i could use a variable instead.
    Business Requirement - My whole intent is to calculate the Age of an incident (Difference between "Reported Date" and current date) and to assign Age Groups (0-1 Days, 2-4 Days,....,20+ Days).
    Edited by: 921713 on Mar 19, 2012 12:23 PM

  • Oracle query help

    Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.8.0 - Production
    Report Builder 10.1.2.0.2
    ORACLE Server Release 10.1.0.4.2
    Oracle Procedure Builder 10.1.2.0.2
    Oracle ORACLE PL/SQL V10.1.0.4.2 - Production
    Oracle CORE    10.1.0.4.0    Production
    Oracle Tools Integration Services 10.1.2.0.2
    Oracle Tools Common Area 10.1.2.0.2
    Oracle Toolkit 2 for Windows 32-bit platforms 10.1.2.0.2
    Resource Object Store 10.1.2.0.2
    Oracle Help 10.1.2.0.2
    Oracle Sqlmgr 10.1.2.0.2
    Oracle Query Builder 10.1.2.0.2 - Production
    PL/SQL Editor (c) WinMain Software (www.winmain.com), v1.0 (Production)
    Oracle ZRC 10.1.2.0.2
    Oracle XML Developers Kit 10.1.0.4.2 - Production
    Oracle Virtual Graphics System 10.1.2.0.2
    Oracle Image 10.1.2.0.2
    Oracle Multimedia Widget 10.1.2.0.2
    Oracle Tools GUI Utilities 10.1.2.0.2
    I have enclosed sample data and also table structure. I need help in getting the query.
    select dept_id,proc_code,override_goal,goal_override_date
      from table2
    where goal_override_date between '02-jan-2014' and '11-jan-2014'
       and dept_id = 10
       and proc_code = 'CP'
    select DEPT_ID, PROC_CODE, DAY_SUNDAY, DAY_MONDAY,
           DAY_TUESDAY, DAY_WEDNESDAY, DAY_THURSDAY,
             DAY_FRIDAY, DAY_SATURDAY
      from table1
    where dept_id =10
    and proc_code = 'CP'; 
    Table1  is kind of maintenance table.
    In Table2 values can be overridden.
    Requirement
    Check to see if there is data in table 2 for the date range . If table2 has no value then take value from table1 for that day the date falls into. Any more clarification please ask me.
    Sundays are all zeros.
    I want this data. and the sum for the date range.
    2-jan-2014  - 3
    3-jan-2014  - 3
    4-jan-2014  - 3
    5-jan-2014  - 0
    6-jan-2014  - 1
    7-jan-2014  - 3
    8-jan-2014  - 5
    9-jan-2014  - 5
    10-jan-2014 - 3
    11-jan-2014 - 3
    Sum for the date range has to be 29
    Sample table and data
    CREATE TABLE TABLE1
      DEPT_ID NUMBER NOT NULL,
      PROC_CODE VARCHAR2(2 BYTE) NOT NULL,
      DAY_SUNDAY NUMBER(4) NOT NULL,
      DAY_MONDAY NUMBER(4) NOT NULL,
      DAY_TUESDAY NUMBER(4) NOT NULL,
      DAY_WEDNESDAY NUMBER(4) NOT NULL,
      DAY_THURSDAY NUMBER(4) NOT NULL,
      DAY_FRIDAY NUMBER(4) NOT NULL,
      DAY_SATURDAY NUMBER(4) NOT NULL
    Insert into TABLE1
      (DEPT_ID, PROC_CODE, DAY_SUNDAY, DAY_MONDAY, DAY_TUESDAY,
      DAY_WEDNESDAY, DAY_THURSDAY, DAY_FRIDAY, DAY_SATURDAY)
    Values
      (10, 'CP', 0, 3, 3,
      3, 3, 3, 3);
    COMMIT;
    CREATE TABLE TABLE2
      DEPT_ID NUMBER NOT NULL,
      PROC_CODE VARCHAR2(2 BYTE) NOT NULL,
      OVERRIDE_GOAL NUMBER(4),
      GOAL_OVERRIDE_DATE DATE NOT NULL
    Insert into TABLE2
      (DEPT_ID, PROC_CODE, OVERRIDE_GOAL, GOAL_OVERRIDE_DATE)
    Values
      (10, 'CP', 1, TO_DATE('01/06/2014 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into TABLE2
      (DEPT_ID, PROC_CODE, OVERRIDE_GOAL, GOAL_OVERRIDE_DATE)
    Values
      (10, 'CP', 3, TO_DATE('01/07/2014 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into TABLE2
      (DEPT_ID, PROC_CODE, OVERRIDE_GOAL, GOAL_OVERRIDE_DATE)
    Values
      (10, 'CP', 5, TO_DATE('01/08/2014 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into TABLE2
      (DEPT_ID, PROC_CODE, OVERRIDE_GOAL, GOAL_OVERRIDE_DATE)
    Values
      (10, 'CP', 5, TO_DATE('01/09/2014 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into TABLE2
      (DEPT_ID, PROC_CODE, OVERRIDE_GOAL, GOAL_OVERRIDE_DATE)
    Values
      (10, 'CP', 3, TO_DATE('01/10/2014 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into TABLE2
      (DEPT_ID, PROC_CODE, OVERRIDE_GOAL, GOAL_OVERRIDE_DATE)
    Values
      (10, 'CP', 3, TO_DATE('01/11/2014 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    COMMIT;
    Help is highly appreciated.

    SELECT dates,
           override_goal,
           SUM(override_goal) OVER()
           FROM(SELECT dates,
                       CASE WHEN EXISTS(SELECT 1
                                        FROM table2 t2
                                        WHERE t2.goal_override_date = qry1.dates
                                        AND t2.dept_id = 10
                                        AND t2.proc_code = 'CP')
                            THEN (SELECT override_goal
                                  FROM table2 t2
                                  WHERE t2.goal_override_date = qry1.dates
                                  AND t2.dept_id = 10
                                  AND t2.proc_code = 'CP')
                       ELSE (SELECT DECODE(days,'SUN',day_sunday,
                                                'MON',day_monday,
                                                'TUE',day_tuesday,
                                                'WED',day_wednesday,
                                                'THU',day_thursday,
                                                'FRI',day_friday,
                                                'SAT',day_saturday )
                              FROM table1)
                       END as override_goal
                FROM (SELECT in_dt1+(LEVEL-1) dates,
                             TO_CHAR(in_dt1+(LEVEL-1),'DY') days
                      FROM(SELECT TO_DATE(&from_date,'DD-MON-YYYY') in_dt1,
                                  TO_DATE(&to_date,'DD-MON-YYYY') in_dt2
                                 FROM dual)
                      CONNECT BY LEVEL <= (in_dt2 - in_dt1)+1) qry1);
    Now run the query it will prompt you for the inputs. You can pass the date values and check the result. Otherwise replace &from_date,&to_date with user inputs

  • Query taking more time

    Iam having nearly 2 crores records at present in my table..
    I want to get the avg of price from my table..
    i put the query like
    select avg(sum(price)) from table group by product_id
    The query taking more than 5 mins to execute...
    is that any other way i can simplify my query?

    Warren:
    Your first query gives:
    SQL> SELECT AVG(SUM(price)) sum_price
      2  FROM t;
    SELECT AVG(SUM(price)) sum_price
    ERROR at line 1:
    ORA-00978: nested group function without GROUP BYand your second gives:
    SQL> SELECT product_id, AVG(SUM(price))
      2  FROM t
      3  GROUP BY product_id;
    SELECT product_id, AVG(SUM(price))
    ERROR at line 1:
    ORA-00937: not a single-group group functionSymon:
    What exactly are you ttrying to accomplish. Your query as posted will calculate the average of the sums of the prices for all product_id values. That is, it is equivalent to:
    SELECT AVG(sum_price)
    FROM (SELECT SUM(price) sum_price
          FROM t
          GROUP BY product_id)So given:
    SQL> SELECT * FROM t;
    PRODUCT_ID      PRICE
    PROD1               5
    PROD1               7
    PROD1              10
    PROD2               3
    PROD2               4
    PROD2               5The sum of the prices per product_id is:
    SQL> SELECT SUM(price) sum_price
      2  FROM t
      3  GROUP BY product_id;
    SUM_PRICE
            22
            12 and the average of that is (22 + 12) / 2 = 17. Is that what you are looking for? If so, then the equivalent query I posted above is at least clearer, but may not be any faster. If this is not what you are looking for, then some sample data and expected results may help. Although, it appears that you need to full scan the table in either case, so that may be as good as it gets.
    John

  • How to enforce index in oracle query

    Hi all
    how to enforce index in oracle query
    Regards

    Use INDEX hint to force Optimizer to use the specfied index.
    You really need to investigate why Optimizer doesn't choose the index. Remember, INDEX SCAN are not always GOOD.
    Jaffar

  • Passing parameters to oracle query

    Hi Everyone,
    I'm a newbie to oracle and need help passing parameters to an oracle query. For example, I need to show all the employees in a certain department.So a list of "DEPT_CODE"'s will be displayed on a webpage and then the selected value will be passed to the query. I currently have this query in MS Access and use the bracket for user input ("[Dept]"). But how can this be done in oracle?
    I am using ASP.NET 2.0 and Crystal Reports XI. Basically I have a webform where users can select the date range and department from a listbox. When the submit button is clicked, the values are passed to the query in crystal reports. For example, I have a query with "DEPT" as a parameter. So I pass the value of the selected listbox item from the webform to the crystal report. But now I have to select data from an oracle database and provide parameters. This is where I need help.
    Thanks in advance
    -Sam

    Duplicate post.
    Refer to this thread
    Passing parameters to oracle query

  • Oracle  query from awr report

    Hi,
    I need to run an Oracle query with the following fields in the AWR report:
    First Query:
    DB Name
    Begin Snap Time
    End Snap Time
    Begin Snap
    End Snap
    Event
    Waits
    Time(s)
    Avg wait (ms)
    % DB time
    Wait Class
    Second Query:
    DB Name
    Begin Snap Time
    End Snap Time
    Begin Snap
    End Snap
    Elapsed Time (s)
    Executions
    Elapsed Time per Exec(s)
    %Total
    %CPU
    %IO
    SQL Id
    SQL Module
    SQL Text
    How Can I write this query?
    Thanks in advance!

    R.Royal wrote:
    Thanks,
    I know how to generate an AWR report but I would like to write a query that takes these fields from oracle views. (DBA_ or V$)
    And the link I sent to you shows you the views required to do that.
    Cheers,

  • Performance optimization : query taking 7mints

    Hi All ,
    Requirement : I need to improve the performance of  custom program ( Program taking more than 7 mints +dump).I checked in runtime analysis and below mention query taking more time .
    Please let me know the approach to minimize the  query time  .
    TYPES: BEGIN OF lty_dberchz1,
               belnr    TYPE dberchz1-belnr,
               belzeile TYPE dberchz1-belzeile,
               belzart  TYPE dberchz1-belzart,
               buchrel  TYPE dberchz1-buchrel,
               tariftyp TYPE dberchz1-tariftyp,
               tarifnr  TYPE dberchz1-tarifnr,
               v_zahl1  TYPE dberchz1-v_zahl1,
               n_zahl1  TYPE dberchz1-n_zahl1,
               v_zahl3  TYPE dberchz1-v_zahl3,
               n_zahl3  TYPE dberchz1-n_zahl3,
               nettobtr TYPE dberchz3-nettobtr,
               twaers   TYPE dberchz3-twaers,
             END   OF lty_dberchz1.
      DATA: lt_dberchz1 TYPE SORTED TABLE OF lty_dberchz1
            WITH NON-UNIQUE KEY belnr belzeile
            INITIAL SIZE 0 WITH HEADER LINE.
    DATA: lt_dberchz1a LIKE TABLE OF lt_dberchz1 WITH HEADER LINE.
    *** ***********************************Taking more time*************************************************
    *Individual line items
        SELECT dberchz1~belnr dberchz1~belzeile
               belzart buchrel tariftyp tarifnr
               v_zahl1 n_zahl1 v_zahl3 n_zahl3
               nettobtr twaers
          INTO TABLE lt_dberchz1
          FROM dberchz1 JOIN dberchz3
          ON dberchz1~belnr = dberchz3~belnr
          AND dberchz1~belzeile = dberchz3~belzeile
          WHERE buchrel  EQ 'X'.
        DELETE lt_dberchz1 WHERE belzart NOT IN r_belzart.     
        LOOP AT lt_dberchz1.
          READ TABLE lt_dberdlb BINARY SEARCH
          WITH KEY billdoc = lt_dberchz1-belnr.
          IF sy-subrc NE 0.
            DELETE lt_dberchz1.
          ENDIF.
        ENDLOOP.
        lt_dberchz1a[] = lt_dberchz1[].
        DELETE lt_dberchz1 WHERE belzart EQ 'ZUTAX1'
                              OR belzart EQ 'ZUTAX2'
                              OR belzart EQ 'ZUTAX3'.
        DELETE lt_dberchz1a WHERE belzart NE 'ZUTAX1'
                              AND belzart NE 'ZUTAX2'
                              AND belzart NE 'ZUTAX3'.
    ***************************second query************************************
    *  SELECT opbel budat vkont partner sto_opbel
        INTO CORRESPONDING FIELDS OF TABLE lt_erdk
        FROM erdk
        WHERE budat IN r_budat
          AND druckdat   NE '00000000'
          AND stokz      EQ space
          AND intopbel   EQ space
          AND total_amnt GT 40000.
    **************************taking more time*********************************
      SORT lt_erdk BY opbel.
      IF lt_erdk[] IS NOT INITIAL.
        SELECT DISTINCT printdoc billdoc vertrag
          INTO CORRESPONDING FIELDS OF TABLE lt_dberdlb
          FROM dberdlb
    * begin of code change by vishal
          FOR ALL ENTRIES IN lt_erdk
          WHERE printdoc = lt_erdk-opbel.
        IF lt_dberdlb[] IS NOT INITIAL.
          SELECT belnr belzart ab bis aus01
                 v_zahl1 n_zahl1 v_zahl3 n_zahl3
            INTO CORRESPONDING FIELDS OF TABLE lt_dberchz1
            FROM dberchz1
            FOR ALL ENTRIES IN lt_dberdlb
            WHERE belnr   EQ lt_dberdlb-billdoc
              AND belzart IN ('ZUTAX1', 'ZUTAX2', 'ZUTAX3').
        ENDIF. "lt_dberdlb
       endif.
    Regards
    Rahul
    Edited by: Matt on Mar 17, 2009 4:17 PM - Added  tags and moved to correct forum

    Run the SQL Trace and tell us where the time is spent,
    see here how to use it:
    SELECT dberchz1~belnr dberchz1~belzeile
               belzart buchrel tariftyp tarifnr
               v_zahl1 n_zahl1 v_zahl3 n_zahl3
               nettobtr twaers
          INTO TABLE lt_dberchz1
          FROM dberchz1 JOIN dberchz3
          ON dberchz1~belnr = dberchz3~belnr
          AND dberchz1~belzeile = dberchz3~belzeile
          WHERE buchrel  EQ 'X'.
    I assume that is this select, but without data is quite useless
    How large are the two tables  dberchz1 JOIN dberchz3
    What are the key fields?
    Is there an index on buchrel
    Please use aliases  dberchz1 as a
                                 INNER JOIN dberchz3 as b
    to which table does buchrel belong?
    I don't know you tables, but buchrel  EQ 'X' seems not selective, so a lot of data
    might be selected.
    lt_dberchz1 TYPE SORTED TABLE OF lty_dberchz1
            WITH NON-UNIQUE KEY belnr belzeile
            INITIAL SIZE 0 WITH HEADER LINE.
        DELETE lt_dberchz1 WHERE belzart NOT IN r_belzart.     
        LOOP AT lt_dberchz1.
          READ TABLE lt_dberdlb BINARY SEARCH
          WITH KEY billdoc = lt_dberchz1-belnr.
          IF sy-subrc NE 0.
            DELETE lt_dberchz1.
          ENDIF.
        ENDLOOP.
        lt_dberchz1a[] = lt_dberchz1[].
        DELETE lt_dberchz1 WHERE belzart EQ 'ZUTAX1'
                              OR belzart EQ 'ZUTAX2'
                              OR belzart EQ 'ZUTAX3'.
        DELETE lt_dberchz1a WHERE belzart NE 'ZUTAX1'
                              AND belzart NE 'ZUTAX2'
                              AND belzart NE 'ZUTAX3'.
    This is really poor coding, there is sorted table ... nice a compelelty different key is
    needed and used .... useless.
    Then there is a loop which is anywy a full processing no sort necessary.
    Where is the read if you use binary search on TABLE lt_dberdlb ?
    Then the tables are again process completely ...
        DELETE lt_dberchz1a WHERE belzart NE 'ZUTAX1'
                              AND belzart NE 'ZUTAX2'
                              AND belzart NE 'ZUTAX3'.
    What is that ???? Are you sure that anything can survive this delete???
    Siegfried

  • Oracle query hints in JPQL - is it possible?

    Sorry, posted to wrong forum... I don't know how to delete it - only edit...
    Hello,
    I am using Sun Java Application Server 9.1 (GlassFish), EJB 3.0 and JPA (TopLink). My database is Oracle.
    Is there any way to specify Oracle query hints (for example, /*+ rule */ in JPQL queries? Or the only way to do it is using native queries?
    Many thanks in advance
    Edited by: Troff_2 on Nov 27, 2007 5:50 AM

    Yes.It is possible.Only need to modify the view for order tracker query need to change.
    You can use decode statement in the query to add status as Processing .
    Please refer the IBE_ORDER_SUM_V view for details.
    Eg:
    decode(oel.meaning,'Booked',"Processing",oel.meaning) from
    oe_lookups        
    oel,

Maybe you are looking for

  • Issue with Webparts while adding in Project Site

    Hi I am getting an error while adding web parts in project site page 2010. Below the steps Open project site --> site actions --> edit page --> click on Add webpart --> ProjectWebApp --> Project fields --> Add Please try and let me know is this possi

  • Variable Screen not displaying correctly

    Our BW install is BI 7.0, with BEx still in the BI 3.5.  We do not have any web-based reporting.  We have deployed the SAP 7.20 GUI with front-end patch 4.  One office is testing the installation with Win 7, Office 2010.  When executing a workbook fr

  • Flat file to XML

    Hi guys, Anyone knows standard functions to convert a flat file to XML? Or maybe from an internal table to XML. Thanks in advance, Ricardo.

  • Link between classes: Reference Error

    Hi, I am still trying to create a movie clip array to make a list of objects appear on stage and have the user interact with them. This will be my game loop class called "LetterArray()". My main class is called "BugGoopFSGame()". After I add the line

  • Papi call  of processGetInstances fail

    Hi al Gurus, i have wls 10 and albpm BEA AquaLogic(TM) BPM Enterprise for Application Server Versione: 6.0.2 Build: #88812 on host: Linux anime 2.6.9-42.ELsmp #1 SMP Wed Jul 12 23:27:17 EDT 2006 i686 i686 i386 GNU/Linux Process: /CatalogueMaintainabi