Query is taking more time to execute in PROD

Hi All,
Can anyone tell me why this query is taking more time when I am using for single trx_number record it is working fine but when I am trying to use all the records it is not fatching any records and it is keep on running.
SELECT DISTINCT OOH.HEADER_ID
,OOH.ORG_ID
,ct.CUSTOMER_TRX_ID
,ool.ship_from_org_id
,ct.trx_number IDP_SHIPMENT_ID
,ctt.type STATUS_CODE
,SYSDATE STATUS_DATE
,ooh.attribute16 IDP_ORDER_NBR --Change based on testing on 21-JUL-2010 in UAT
,lpad(rac_bill.account_number,6,0) IDP_BILL_TO_CUSTOMER_NBR
,rac_bill.orig_system_reference
,rac_ship_party.party_name SHIP_TO_NAME
,raa_ship_loc.address1 SHIP_TO_ADDR1
,raa_ship_loc.address2 SHIP_TO_ADDR2
,raa_ship_loc.address3 SHIP_TO_ADDR3
,raa_ship_loc.address4 SHIP_TO_ADDR4
,raa_ship_loc.city SHIP_TO_CITY
,NVL(raa_ship_loc.state,raa_ship_loc.province) SHIP_TO_STATE
,raa_ship_loc.country SHIP_TO_COUNTRY_NAME
,raa_ship_loc.postal_code SHIP_TO_ZIP
,ooh.CUST_PO_NUMBER CUSTOMER_ORDER_NBR
,ooh.creation_date CUSTOMER_ORDER_DATE
,ool.actual_shipment_date DATE_SHIPPED
,DECODE(mp.organization_code,'CHP', 'CHESAPEAKE'
,'CSB', 'CHESAPEAKE'
,'DEP', 'CHESAPEAKE'
,'CHESAPEAKE') SHIPPED_FROM_LOCATION --'MEMPHIS' --'HOUSTON'
,ooh.freight_carrier_code FREIGHT_CARRIER
,NVL(XX_FSG_NA_FASTRAQ_IFACE.get_invoice_amount ('FREIGHT',ct.customer_trx_id,ct.org_id),0)
+ NVL(XX_FSG_NA_FASTRAQ_IFACE.get_line_fr_amt ('FREIGHT',ct.customer_trx_id,ct.org_id),0)FREIGHT_CHARGE
,ooh.freight_terms_code FREIGHT_TERMS
,'' IDP_BILL_OF_LADING
,(SELECT WAYBILL
FROM WSH_DELIVERY_DETAILS_OE_V
WHERE -1=-1
AND SOURCE_HEADER_ID = ooh.header_id
AND SOURCE_LINE_ID = ool.line_id
AND ROWNUM =1) WAYBILL_CARRIER
,'' CONTAINERS
,ct.trx_number INVOICE_NBR
,ct.trx_date INVOICE_DATE
,NVL(XX_FSG_NA_FASTRAQ_IFACE.get_invoice_amount ('LINE',ct.customer_trx_id,ct.org_id),0) +
NVL(XX_FSG_NA_FASTRAQ_IFACE.get_invoice_amount ('TAX',ct.customer_trx_id,ct.org_id),0) +
NVL(XX_FSG_NA_FASTRAQ_IFACE.get_invoice_amount ('FREIGHT',ct.customer_trx_id,ct.org_id),0)INVOICE_AMOUNT
,NULL IDP_TAX_IDENTIFICATION_NBR
,NVL(XX_FSG_NA_FASTRAQ_IFACE.get_invoice_amount ('TAX',ct.customer_trx_id,ct.org_id),0) TAX_AMOUNT_1
,NULL TAX_DESC_1
,NULL TAX_AMOUNT_2
,NULL TAX_DESC_2
,rt.name PAYMENT_TERMS
,NULL RELATED_INVOICE_NBR
,'Y' INVOICE_PRINT_FLAG
FROM ra_customer_trx_all ct
,ra_cust_trx_types_all ctt
,hz_cust_accounts rac_ship
,hz_cust_accounts rac_bill
,hz_parties rac_ship_party
,hz_locations raa_ship_loc
,hz_party_sites raa_ship_ps
,hz_cust_acct_sites_all raa_ship
,hz_cust_site_uses_all su_ship
,ra_customer_trx_lines_all rctl
,oe_order_lines_all ool
,oe_order_headers_all ooh
,mtl_parameters mp
,ra_terms rt
,OE_ORDER_SOURCES oos
,XLA_AR_INV_AEL_SL_V XLA_AEL_SL_V
WHERE ct.cust_trx_type_id = ctt.cust_trx_type_id
AND ctt.TYPE <> 'BR'
AND ct.org_id = ctt.org_id
AND ct.ship_to_customer_id = rac_ship.cust_account_id
AND ct.bill_to_customer_id = rac_bill.cust_account_id
AND rac_ship.party_id = rac_ship_party.party_id
AND su_ship.cust_acct_site_id = raa_ship.cust_acct_site_id
AND raa_ship.party_site_id = raa_ship_ps.party_site_id
AND raa_ship_loc.location_id = raa_ship_ps.location_id
AND ct.ship_to_site_use_id = su_ship.site_use_id
AND su_ship.org_id = ct.org_id
AND raa_ship.org_id = ct.org_id
AND ct.customer_trx_id = rctl.customer_trx_id
AND ct.org_id = rctl.org_id
AND rctl.interface_line_attribute6 = to_char(ool.line_id)
AND rctl.org_id = ool.org_id
AND ool.header_id = ooh.header_id
AND ool.org_id = ooh.org_id
AND mp.organization_id = ool.ship_from_org_id
AND ooh.payment_term_id = rt.term_id
AND xla_ael_sl_v.last_update_date >= NVL(p_last_update_date,xla_ael_sl_v.last_update_date)
AND ooh.order_source_id = oos.order_source_id --Change based on testing on 19-May-2010
AND oos.name = 'FASTRAQ' --Change based on testing on 19-May-2010
AND ooh.org_id = g_org_id --Change based on testing on 19-May-2010
AND ool.flow_status_code = 'CLOSED'
AND xla_ael_sl_v.trx_hdr_id = ct.customer_trx_id
AND trx_hdr_table = 'CT'
AND xla_ael_sl_v.gl_transfer_status = 'Y'
AND xla_ael_sl_v.accounted_dr IS NOT NULL
AND xla_ael_sl_v.org_id = ct.org_id;
-- AND ct.trx_number = '2000080';
}

Hello Friend,
You query will definitely take more time or even fail in PROD,becuase the way it is written. Here are my few observations, may be it can help :-
1. XLA_AR_INV_AEL_SL_V XLA_AEL_SL_V : Never use a view inside such a long query , becuase View is just a window to the records.
and when used to join other table records, then all those tables which are used to create a view also becomes part of joining conition.
First of all please check if you really need this view. I guess you are using to check if the records have been created as Journal entries or not ?
Please check the possbility of finding it through other AR tables.
2. Remove _ALL tables instead use the corresponding org specific views (if you are in 11i ) or the sysnonymns ( in R12 )
For example : For ra_cust_trx_types_all use ra_cust_trx_types.
This will ensure that the query will execute only for those ORG_IDs which are assigned to that responsibility.
3. Check with the DBA whether the GATHER SCHEMA STATS have been run atleast for ONT and RA tables.
You can also check the same using
SELECT LAST_ANALYZED FROM ALL_TABLES WHERE TABLE_NAME = 'ra_customer_trx_all'.
If the tables are not analyzed , the CBO will not be able to tune your query.
4. Try to remove the DISTINCT keyword. This is the MAJOR reason for this problem.
5. If its a report , try to separate the logic in separate queries ( using a procedure ) and then populate the whole data in custom table, and use this custom table for generating the
report.
Thanks,
Neeraj Shrivastava
[email protected]
Edited by: user9352949 on Oct 1, 2010 8:02 PM
Edited by: user9352949 on Oct 1, 2010 8:03 PM

Similar Messages

  • Query is taking more time to execute

    Hi,
    Query is taking more time to execute.
    But when i execute same query in other server then it is giving immediate output.
    What is the reason of it.
    thanks in advance.

    'My car doesn't start, please help me to start my car'
    Do you think we are clairvoyant?
    Or is your salary subtracted for every letter you type here?
    Please be aware this is not a chatroom, and we can not see your webcam.
    Sybrand Bakker
    Senior Oracle DBA

  • Sql query is taking more time

    Hi all,
    db:oracle 9i
    I am facing below query prob.
    prob is that query is taking more time 45 min than earliar (10 sec).
    please any one suggest me .....
    SQL> SELECT MAX (tdar1.ID) ID, tdar1.request_id, tdar1.lolm_transaction_id,
    2 tdar1.transaction_version
    3 FROM transaction_data_arc tdar1
    4 WHERE tdar1.transaction_name ='O96U '
    5 AND tdar1.transaction_type = 'REQUEST'
    6 AND tdar1.message_type_code ='PCN'
    7 AND NOT EXISTS (
    8 SELECT NULL
    9 FROM transaction_data_arc tdar2
    10 WHERE tdar2.request_id = tdar1.request_id
    11 AND tdar2.lolm_transaction_id != tdar1.lolm_transaction_id
    12 AND tdar2.ID > tdar1.ID)
    13 GROUP BY tdar1.request_id,
    14 tdar1.lolm_transaction_id,
    15 tdar1.transaction_version;
    Execution Plan
    0 SELECT STATEMENT Optimizer=CHOOSE (Cost=17 Card=1 Bytes=42)
    1 0 SORT (GROUP BY) (Cost=12 Card=1 Bytes=42)
    2 1 FILTER
    3 2 TABLE ACCESS (BY INDEX ROWID) OF 'TRANSACTION_DATA_ARC
    ' (Cost=1 Card=1 Bytes=42)
    4 3 INDEX (RANGE SCAN) OF 'NK_TDAR_2' (NON-UNIQUE) (Cost
    =3 Card=1)
    5 2 TABLE ACCESS (BY INDEX ROWID) OF 'TRANSACTION_DATA_ARC
    ' (Cost=5 Card=918 Bytes=20196)
    6 5 INDEX (RANGE SCAN) OF 'NK_TDAR_7' (NON-UNIQUE) (Cost
    =8 Card=4760)

    prob is that query is taking more time 45 min than earliar (10 sec).Then something must have changed (data growth/stale statistics/...?).
    You should post as much details as possible, how and what it is described in the FAQ, see:
    *3. How to improve the performance of my query? / My query is running slow*.
    When your query takes too long...
    How to post a SQL statement tuning request
    SQL and PL/SQL FAQ
    Also, given your database version, using NOT IN instead of NOT EXISTS might make a difference (but they're not the same).
    See: SQL and PL/SQL FAQ

  • Update query which taking more time

    Hi
    I am running an update query which takeing more time any help to run this fast.
    update arm538e_tmp t
    set t.qtr5 =(select (sum(nvl(m.net_sales_value,0))/1000) from mnthly_sales_actvty m
    where m.vndr#=t.vndr#
    and m.cust_type_cd=t.cust_type
    and m.cust_type_cd<>13
    and m.yymm between 201301 and 201303
    group by m.vndr#,m.cust_type_cd;
    help will be appreciable
    thank you
    Edited by: 960991 on Apr 16, 2013 7:11 AM

    960991 wrote:
    Hi
    I am running an update query which takeing more time any help to run this fast.
    update arm538e_tmp t
    set t.qtr5 =(select (sum(nvl(m.net_sales_value,0))/1000) from mnthly_sales_actvty m
    where m.vndr#=t.vndr#
    and m.cust_type_cd=t.cust_type
    and m.cust_type_cd13
    and m.yymm between 201301 and 201303
    group by m.vndr#,m.cust_type_cd;
    help will be appreciable
    thank youUpdates with subqueries can be slow. Get an execution plan for the update to see what SQL is doing.
    Some things to look at ...
    1. Are you sure you posted the right SQL? I could not "balance" the parenthesis - 4 "(" and 3 ")"
    2. Unnecessary "(" ")" in the subquery "(sum" are confusing
    3. Updates with subqueries can be slow. The tqtr5 value seems to evaluate to a constant. You might improve performance by computing the value beforehand and using a variable instead of the subquery
    4. Subquery appears to be correlated - good! Make sure the subquery is properly indexed if it reads < 20% of the rows in the table (this figure depends on the version of Oracle)
    5. Is tqtr5 part of an index? It is a bad idea to update indexed columns

  • Quesry taking more time to execute

    Dear All,
    User complained that his query is taking more time than yesterday and DB performance is also very slow, so what would be your strategy to check and fix the problem.
    What could be the right approach to check and fix this.
    Regards,
    DevD!
    Edited by: user12138514 on Nov 8, 2009 9:35 PM

    And here is the cause list for slow performance:
    Slow Network connection.
    Bad Connection management.
    Bad Use of Cursors and the Shared Pool
    Bad SQL or Query is not perfectly tune or not using bind variables.
    Use of nonstandard initialization parameters.
    Getting Database I/O Wrong
    Redo Log Setup Problems
    Serialization of data blocks in the buffer cache due to lack of free lists, free list groups, transaction slots (INITRANS), or shortage of rollback segments.
    Long Full Table Scans.
    High Amounts of Recursive (SYS) SQL
    Deployment and Migration Errors
    Table require analyzed.
    Table require indexed.
    Overparsing.
    You have old discs.
    Not enough memory.
    SGA is too small or too big.
    Same for cache buffer.
    Your OS need tuning.
    Your disc is full.
    Running so many instances on a single server.
    You applications are badly written.
    Your applications were ported from Sybase or Microsoft SQL Server.
    Your applications were ported from DB2.
    Your applications dynamically create temp tables.
    Someone wrote referential integrity using triggers, java, vb ...
    Someone wrote replication using triggers, java, vb ...
    Someone wrote a sequence using max + 1.
    Table datatypes are not as per DBMS concepts; like Dates and numbers are stored as strings.
    The statistics are not up to date.
    There are no statistics.
    What are statistics?
    We are using RBO.
    That's a few of the possible causes I could think of, there are lots of others.
    -To analyze your application, you can install Statspack. It will give you some indications.
    Hth
    Girish Sharma

  • Stopping a Query taking more time to execute in runtime in Oracle Forms.

    Hi,
    In the present application one of the oracle form screen is taking long time to execute a query, user wanted an option to stop the query in between and browse the result (whatever has been fetched before stopping the query).
    We have tried three approach.
    1. set max fetch record in form and block level.
    2. set max fetch time in form and block level.
    in above two method does not provide the appropiate solution for us.
    3. the third approach we applied is setting the interaction mode to "NON BLOCKING" at the form level.
    It seems to be worked, while the query took long time to execute, oracle app server prompts an message to press Esc to cancel the query and it a displaying the results fetched upto that point.
    But the drawback is one pressing esc, its killing the session itself. which is causing the entire application to collapse.
    Please suggest if there is any alternative approach for this or how to overcome this perticular scenario.
    This kind of facility is alreday present in TOAD and PL/SQL developer where we can stop an executing query and browse the results fetched upto that point, is the similar facility is avialable in oracle forms ,please suggest.
    Thanks and Regards,
    Suraj
    Edited by: user10673131 on Jun 25, 2009 4:55 AM

    Hello Friend,
    You query will definitely take more time or even fail in PROD,becuase the way it is written. Here are my few observations, may be it can help :-
    1. XLA_AR_INV_AEL_SL_V XLA_AEL_SL_V : Never use a view inside such a long query , becuase View is just a window to the records.
    and when used to join other table records, then all those tables which are used to create a view also becomes part of joining conition.
    First of all please check if you really need this view. I guess you are using to check if the records have been created as Journal entries or not ?
    Please check the possbility of finding it through other AR tables.
    2. Remove _ALL tables instead use the corresponding org specific views (if you are in 11i ) or the sysnonymns ( in R12 )
    For example : For ra_cust_trx_types_all use ra_cust_trx_types.
    This will ensure that the query will execute only for those ORG_IDs which are assigned to that responsibility.
    3. Check with the DBA whether the GATHER SCHEMA STATS have been run atleast for ONT and RA tables.
    You can also check the same using
    SELECT LAST_ANALYZED FROM ALL_TABLES WHERE TABLE_NAME = 'ra_customer_trx_all'.
    If the tables are not analyzed , the CBO will not be able to tune your query.
    4. Try to remove the DISTINCT keyword. This is the MAJOR reason for this problem.
    5. If its a report , try to separate the logic in separate queries ( using a procedure ) and then populate the whole data in custom table, and use this custom table for generating the
    report.
    Thanks,
    Neeraj Shrivastava
    [email protected]
    Edited by: user9352949 on Oct 1, 2010 8:02 PM
    Edited by: user9352949 on Oct 1, 2010 8:03 PM

  • "3.x Analyzer Server" EVENT taking more Time when Executing Query

    Hi All,
    When I am Executing the Query Through RSRT   taking more time. When I have checked the statistics
    and observed that "3.x Analyzer Server" EVENT taking more Time .
    What I have to do , How I will reduce this 3.x Analyzer Server EVENT time.
    Please Suggest me.
    Thanks,
    Kiran Manyam

    Hello,
    Chk this on query performance:
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/ce7fb368-0601-0010-64ba-fadc985a1f94
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/4c0ab590-0201-0010-bd9a-8332d8b4f09c
    Query Performance
    Reg,
    Dhanya

  • Trunc taking more time to execute..........

    Hiii
    I running a query that is including TRUNC in where condition. But it is taking more time time to execute. Query is ::::::::::
    SELECT POD.REQ_DISTRIBUTION_ID, X.*
    FROM
    SELECT MSI.SEGMENT1||'.'||MSI.SEGMENT2||'.'||MSI.SEGMENT3||'.'||MSI.SEGMENT4 ITEM, RT.TRANSACTION_TYPE,
         MSI.DESCRIPTION, rt.TRANSACTION_ID,RT.PARENT_TRANSACTION_ID,
         RSH.RECEIPT_NUM,
         RSH.SHIP_TO_ORG_ID,
         TRUNC(RT.TRANSACTION_DATE) RCP_DATE,
         RSL.QUANTITY_RECEIVED RCV_QTY,
         PLLA.SHIPMENT_NUM,
         PLA.LINE_NUM PO_LINE,
         PHA.SEGMENT1 PO_NUM,
         PHA.CREATION_DATE,
         PHA.APPROVED_DATE,
         PLA.QUANTITY PO_QTY,
         RSH.SHIPMENT_HEADER_ID,
         RSL.SHIPMENT_LINE_ID,
         PLLA.LINE_LOCATION_ID
    FROM PO_HEADERS_ALL PHA,
         PO_LINES_ALL PLA,
         MTL_SYSTEM_ITEMS MSI,
         RCV_SHIPMENT_HEADERS RSH,
         RCV_SHIPMENT_LINES RSL,
         RCV_TRANSACTIONS RT,
         PO_LINE_LOCATIONS_ALL PLLA
    WHERE PHA.PO_HEADER_ID = PLA.PO_HEADER_ID
    AND     PHA.PO_HEADER_ID = RSL.PO_HEADER_ID
    AND     PHA.PO_HEADER_ID = PLLA.PO_HEADER_ID
    AND     PHA.ORG_ID = PLLA.ORG_ID
    AND     PLA.ITEM_ID = MSI.INVENTORY_ITEM_ID
    AND     PLA.PO_LINE_ID = RSL.PO_LINE_ID
    AND     MSI.INVENTORY_ITEM_ID = RSL.ITEM_ID
    AND     MSI.ORGANIZATION_ID = RSH.SHIP_TO_ORG_ID
    AND     RSH.SHIPMENT_HEADER_ID = RSL.SHIPMENT_HEADER_ID
    AND     RSH.SHIPMENT_HEADER_ID = RT.SHIPMENT_HEADER_ID
    AND     RSL.SHIPMENT_LINE_ID = RT.SHIPMENT_LINE_ID
    AND     RSL.PO_LINE_ID = PLLA.PO_LINE_ID
    AND     RT.TRANSACTION_TYPE = 'RECEIVE'
    AND     NVL(MSI.ENABLED_FLAG,'N') = 'Y'
    AND     NVL(RSL.QUANTITY_RECEIVED,0) > 0
    AND     PHA.ORG_ID = :P_ORG_ID
    AND        TRUNC(RT.TRANSACTION_DATE) BETWEEN :P_FROM_DATE AND :P_TO_DATE ) X, PO_DISTRIBUTIONS_ALL POD
    WHERE POD.LINE_LOCATION_ID = X.LINE_LOCATION_ID
    How can i execute it fast. Any alternate for TRUNC..?
    PS

    You could use a function based index,
    create index idx_trunc_trans_date on RCV_TRANSACTIONS(TRUNC(TRANSACTION_DATE));I guess the trunc you are using will not be of any use unless you are having any time format in your p_from_date and p_to_date or you enter same date for to and from dates.
    Trunc just truncates the time in the date and resets it begining of the day. I dont think you need trunc at all.
    Just do
    IF P_FROM_DATE AND P_TO_DATE
    then
    l_to_date := (p_to_date+1)-(1/(24*3600))
    -- use local variables
    then useAND RT.TRANSACTION_DATE BETWEEN :P_FROM_DATE AND L_TO_DATE
    I believe you should get the same reults unless you have time in your from and to date parameters.
    If you are getting, same results, just remove the trunc.
    G.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Performance tunned report taking more time to execute - URGENT

    Dear Experts,
    In One Report Program is Taking long time to execute at background session, I am Taking That Report To Tune The Performance But This is taking 12 hours more to excute .........
    The Code is given below.
    Before Tune.
    DATA  :  BEGIN OF ITAB OCCURS 0,
            LGOBE    LIKE T001L-LGOBE,
            105DT    LIKE MKPF-BUDAT,
            XBLNR    LIKE MKPF-XBLNR,
            BEDAT    LIKE EKKO-BEDAT,
            LIFNR    LIKE EKKO-LIFNR,
            NAME1    LIKE LFA1-NAME1,
            EKKO     LIKE EKKO-BEDAT,
            BISMT    LIKE MARA-BISMT,
            MAKTX    LIKE MAKT-MAKTX,
            NETPR    LIKE EKPO-NETPR,
            PEINH    LIKE EKPO-PEINH,
            VALUE    TYPE P DECIMALS 2,
            DISPO    LIKE MARC-DISPO,
            DSNAM    LIKE T024D-DSNAM,
            AGE      TYPE P DECIMALS 0,
            PARLIFNR LIKE EKKO-LIFNR,
            PARNAME1 LIKE LFA1-NAME1,
             MBLNR    LIKE MSEG-MBLNR,
             MJAHR    LIKE MSEG-MJAHR,
             ZEILE    LIKE MSEG-ZEILE,
             BWART    LIKE MSEG-BWART,
             MATNR    LIKE MSEG-MATNR,
             WERKS    LIKE MSEG-WERKS,
             LIFNR    LIKE MSEG-LIFNR,
             MENGE    LIKE MSEG-MENGE,
             MEINS    LIKE MSEG-MEINS,
             EBELN    LIKE MSEG-EBELN,
             EBELP    LIKE MSEG-EBELP,
             LGORT    LIKE MSEG-LGORT,
             SMBLN    LIKE MSEG-SMBLN,
             BUKRS    LIKE MSEG-BUKRS,
             GSBER    LIKE MSEG-GSBER,
             INSMK    LIKE MSEG-INSMK,
             XAUTO    LIKE MSEG-XAUTO,
             END OF ITAB.
    SELECT MBLNR MJAHR ZEILE BWART MATNR WERKS LIFNR MENGE MEINS
             EBELN EBELP LGORT SMBLN BUKRS GSBER INSMK XAUTO
             FROM MSEG
             INTO CORRESPONDING FIELDS OF TABLE ITAB
             WHERE WERKS  EQ P_WERKS AND
                   MBLNR  IN S_MBLNR AND
                   BWART  EQ '105'   and
                   mblnr ne '5002361303' and
                   mblnr ne '5003501080' and
                   mblnr ne '5002996300' and
                   mblnr ne '5002996407' AND
                    mblnr ne '5003587026' AND
                    mblnr ne '5003587026' AND
                    mblnr ne '5003493186' AND
                    mblnr ne '5002720583' AND
                    mblnr ne '5002928122' AND
                    mblnr ne '5002628263'.
    After tune.
    TYPES :  BEGIN OF ST_ITAB ,
             MBLNR    LIKE MSEG-MBLNR,
             MJAHR    LIKE MSEG-MJAHR,
             ZEILE    LIKE MSEG-ZEILE,
             BWART    LIKE MSEG-BWART,
             MATNR    LIKE MSEG-MATNR,
             WERKS    LIKE MSEG-WERKS,
             LIFNR    LIKE MSEG-LIFNR,
             MENGE    LIKE MSEG-MENGE,
             MEINS    LIKE MSEG-MEINS,
             EBELN    LIKE MSEG-EBELN,
             EBELP    LIKE MSEG-EBELP,
             LGORT    LIKE MSEG-LGORT,
             SMBLN    LIKE MSEG-SMBLN,
             BUKRS    LIKE MSEG-BUKRS,
             GSBER    LIKE MSEG-GSBER,
             INSMK    LIKE MSEG-INSMK,
             XAUTO    LIKE MSEG-XAUTO,
            END OF ST_ITAB.
    DATA : ITAB TYPE STANDARD TABLE OF ST_ITAB WITH HEADER LINE.
    SELECT MBLNR MJAHR ZEILE BWART MATNR WERKS LIFNR MENGE MEINS
             EBELN EBELP LGORT SMBLN BUKRS GSBER INSMK XAUTO
             FROM MSEG
             INTO TABLE ITAB
             WHERE WERKS  EQ P_WERKS AND
                   MBLNR  IN S_MBLNR AND
                   BWART  EQ '105'   AND
                   MBLNR NE '5002361303' AND
                   MBLNR NE '5003501080' AND
                   MBLNR NE '5002996300' AND
                   MBLNR NE '5002996407' AND
                    MBLNR NE '5003587026' AND
                    MBLNR NE '5003587026' AND
                    MBLNR NE '5003493186' AND
                    MBLNR NE '5002720583' AND
                    MBLNR NE '5002928122' AND
                    MBLNR NE '5002628263'.
    PLEASE GIVE ME THE SOULUTION......
    Reward avail for useful answer
    thanks in adv,
    jai.m

    Hi.
    The Select statment accessing MSEG Table is Slow Many a times.
    To Improve the performance of  MSEG.
    1.Check for the proper notes in the Service Market Place if you are working for CIN version.
    2.Index the MSEG table
    2.Check and limit the Columns in the Select statment .
    Possible Way.
    SELECT MBLNR MJAHR ZEILE BWART MATNR WERKS LIFNR MENGE MEINS
    EBELN EBELP LGORT SMBLN BUKRS GSBER INSMK XAUTO
    FROM MSEG
    INTO CORRESPONDING FIELDS OF TABLE ITAB
    WHERE WERKS EQ P_WERKS AND
    MBLNR IN S_MBLNR AND
    BWART EQ '105' .
    Delete itab where itab EQ '5002361303'
    Delete itab where itab EQ  '5003501080' 
    Delete itab where itab EQ  '5002996300'
    Delete itab where itab EQ '5002996407'
    Delete itab where itab EQ '5003587026'
    Delete itab where itab EQ  '5003587026'
    Delete itab where itab EQ  '5003493186'
    Delete itab where itab EQ  '5002720583'
    Delete itab where itab EQ '5002928122'
    Delete itab where itab EQ '5002628263'.
    Select
    Regards
    Bala.M
    Edited by: Bala Malvatu on Feb 7, 2008 9:18 PM

  • Query is taking long time to execute after migrating to 10g r2

    Hi
    We recently migrated the database from 9i to 10gr2 ((10.2.0.2.0).. This query was running in acceptable time before the upgrade in 9i.. Now it is taking a long long time to execute this... Can you please let me know what should i do to improve the performance now.. We are running stats everyday..
    Thanks for your help,
    Shree
    ======================================================================================
    SELECT cr.cash_receipt_id
    ,cr.pay_from_customer
    ,cr.receipt_number
    ,cr.receipt_date
    ,cr.amount
    ,cust.account_number
    ,crh.gl_date
    ,cr.set_of_books_id
    ,sum(ra.amount_applied) amount_applied
    FROM AR_CASH_RECEIPTS_ALL cr
    ,AR_RECEIVABLE_APPLICATIONS_ALL ra
    ,hz_cust_accounts cust
    ,AR_CASH_RECEIPT_HISTORY_ALL crh
    ,GL_PERIOD_STATUSES gps
    ,FND_APPLICATION app
    WHERE cr.cash_receipt_id = ra.cash_receipt_id
    AND ra.status = 'UNAPP'
    AND cr.status <> 'REV'
    AND cust.cust_account_id = cr.pay_from_customer
    AND substr(cust.account_number,1,2) <> 'SI' -- Don't allocate Unapplied receipts FOR SI customers
    AND crh.cash_receipt_id = cr.cash_receipt_id
    AND app.application_id = gps.application_id
    AND app.application_short_name = 'AR'
    AND gps.period_name = 'May-07'
    AND crh.gl_date <= gps.end_date
    AND cr.receipt_number not like 'WH%'
    -- AND cust.customer_number = '0000079260001'
    GROUP BY cr.cash_receipt_id
    ,cr.pay_from_customer
    ,cr.receipt_number
    ,cr.receipt_date
    ,cr.amount
    ,cust.account_number
    ,crh.gl_date
    ,cr.set_of_books_id
    HAVING sum(ra.amount_applied) > 0;
    =========================================================================================
    Here is the explain plan in 10g r2 (10.2.0.2.0)
    PLAN_TABLE_OUTPUT
    Plan hash value: 2617075047
    | Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)|
    | 0 | SELECT STATEMENT | | 92340 | 10M| | 513K (1)|
    |* 1 | FILTER | | | | | |
    | 2 | HASH GROUP BY | | 92340 | 10M| 35M| 513K (1)|
    | 3 | TABLE ACCESS BY INDEX ROWID | AR_RECEIVABLE_APPLICATIONS_ALL | 2 | 34 |
    | 4 | NESTED LOOPS | | 184K| 21M| | 510K (1)|
    |* 5 | HASH JOIN | | 99281 | 9M| 3296K| 176K (1)|
    |* 6 | TABLE ACCESS FULL | HZ_CUST_ACCOUNTS | 112K| 1976K| | 22563 (1)|
    |* 7 | HASH JOIN | | 412K| 33M| 25M| 151K (1)|
    | 8 | TABLE ACCESS BY INDEX ROWID | AR_CASH_RECEIPT_HISTORY_ALL | 332K| 4546K|
    | 9 | NESTED LOOPS | | 498K| 19M| | 26891 (1)|
    | 10 | NESTED LOOPS | | 2 | 54 | | 4 (0)|
    | 11 | TABLE ACCESS BY INDEX ROWID| FND_APPLICATION | 1 | 8 | | 1 (0)|
    |* 12 | INDEX UNIQUE SCAN | FND_APPLICATION_U3 | 1 | | | 0 (0)|
    | 13 | TABLE ACCESS BY INDEX ROWID| GL_PERIOD_STATUSES | 2 | 38 | | 3 (0)
    |* 14 | INDEX RANGE SCAN | GL_PERIOD_STATUSES_U1 | 1 | | | 2 (0)|
    |* 15 | INDEX RANGE SCAN | AR_CASH_RECEIPT_HISTORY_N2 | 332K| | | 1011 (1)
    PLAN_TABLE_OUTPUT
    |* 16 | TABLE ACCESS FULL | AR_CASH_RECEIPTS_ALL | 5492K| 235M| | 108K
    |* 17 | INDEX RANGE SCAN | AR_RECEIVABLE_APPLICATIONS_N1 | 4 | | | 2
    Predicate Information (identified by operation id):
    1 - filter(SUM("RA"."AMOUNT_APPLIED")>0)
    5 - access("CUST"."CUST_ACCOUNT_ID"="CR"."PAY_FROM_CUSTOMER")
    6 - filter(SUBSTR("CUST"."ACCOUNT_NUMBER",1,2)<>'SI')
    7 - access("CRH"."CASH_RECEIPT_ID"="CR"."CASH_RECEIPT_ID")
    12 - access("APP"."APPLICATION_SHORT_NAME"='AR')
    14 - access("APP"."APPLICATION_ID"="GPS"."APPLICATION_ID" AND "GPS"."PERIOD_NAME"='May-07')
    filter("GPS"."PERIOD_NAME"='May-07')
    15 - access("CRH"."GL_DATE"<="GPS"."END_DATE")
    16 - filter("CR"."STATUS"<>'REV' AND "CR"."RECEIPT_NUMBER" NOT LIKE 'WH%')
    17 - access("CR"."CASH_RECEIPT_ID"="RA"."CASH_RECEIPT_ID" AND "RA"."STATUS"='UNAPP')
    filter("RA"."CASH_RECEIPT_ID" IS NOT NULL)
    Here is the explain plan in 9i
    Execution Plan
    0 SELECT STATEMENT Optimizer=CHOOSE (Cost=445977 Card=78530 By
    tes=9423600)
    1 0 FILTER
    2 1 SORT (GROUP BY) (Cost=445977 Card=78530 Bytes=9423600)
    3 2 HASH JOIN (Cost=443717 Card=157060 Bytes=18847200)
    4 3 HASH JOIN (Cost=99563 Card=94747 Bytes=9758941)
    5 4 TABLE ACCESS (FULL) OF 'HZ_CUST_ACCOUNTS' (Cost=12
    286 Card=110061 Bytes=1981098)
    6 4 HASH JOIN (Cost=86232 Card=674761 Bytes=57354685)
    7 6 TABLE ACCESS (BY INDEX ROWID) OF 'AR_CASH_RECEIP
    T_HISTORY_ALL' (Cost=17532 Card=542304 Bytes=7592256)
    8 7 NESTED LOOPS (Cost=17536 Card=809791 Bytes=332
    01431)
    9 8 NESTED LOOPS (Cost=4 Card=1 Bytes=27)
    10 9 TABLE ACCESS (BY INDEX ROWID) OF 'FND_APPL
    ICATION' (Cost=1 Card=1 Bytes=8)
    11 10 INDEX (UNIQUE SCAN) OF 'FND_APPLICATION_
    U3' (UNIQUE)
    12 9 TABLE ACCESS (BY INDEX ROWID) OF 'GL_PERIO
    D_STATUSES' (Cost=3 Card=1 Bytes=19)
    13 12 INDEX (RANGE SCAN) OF 'GL_PERIOD_STATUSE
    S_U1' (UNIQUE) (Cost=2 Card=1)
    14 8 INDEX (RANGE SCAN) OF 'AR_CASH_RECEIPT_HISTO
    RY_N2' (NON-UNIQUE) (Cost=1740 Card=542304)
    15 6 TABLE ACCESS (FULL) OF 'AR_CASH_RECEIPTS_ALL' (C
    ost=60412 Card=8969141 Bytes=394642204)
    16 3 TABLE ACCESS (FULL) OF 'AR_RECEIVABLE_APPLICATIONS_A
    LL' (Cost=337109 Card=15613237 Bytes=265425029)

    Hi,
    The plan between 9i and 10g is pretty the same but the amount of data fetched has considerably increased. I guess the query was performing slow even in 9i.
    The AR_CASH_RECEIPT_HISTORY_ALL is presently having 332000 rows in 10g where as it was 17532 in 9i.
    AR_CASH_RECEIPT_HISTORY_N2 is now having 332,000 rows in 10g where as in 9i it had 1,740
    Try creating some indexes on
    AR_CASH_RECEIPTS_ALL
    hz_cust_accounts

  • Report taking more time to execute

    Hi,
       I Have created a report on " 0FIGL_O02 " General Ledger: Line Items(DSO)
      This report is creates for document details . so using this report i want to creat
       jump report. But When i am running the report it is taking more tme.
      variable sellections i uesed for this report.
    1. company code
    2.G/L Account
    3.Posting date
    there are no caliculations for this report.  But it is taaking more time and not getting
    executed.
    plz sugest.
    Regards,
    prasad.

    Hi,
    Please rebuild the statistics of the ODS.
    Also check the various options available below:
    ODS Performance
    -Vikram

  • Query is taking more time

    Hi ,
    I am using oracle 10g .My query is as below
    SELECT /*+ PARALLEL(s ,4) */
    s.*
    FROM test_01_ext a,
    test_opn_acc_ext b
    WHERE a.site_no = b.site_no (+)
    AND a.cntry_cd = b.Loc_cntry_code (+)
    both the tables are external tables having millions of record taking more than 7 hrs for execution. Can anybody help in this regards

    Note the name of this forum is "SQL Developer *(Not for general SQL/PLSQL questions)*", so only for issues with the SQL Developer tool. Please post these questions under the dedicated [SQL And PL/SQL|https://forums.oracle.com/forums/forum.jspa?forumID=75] forum.
    Regards,
    K.

  • Collection function taking more time to execute

    Hi all,
    I am using a collection function in my sql_report it is taking plenty of time to return rows, is there any way to get the resulted rows(using collection) without consuming more time.
    SELECT tab_to_string(CAST(COLLECT(wot_vw."Name") AS t_varchar2_tab)) FROM  REPORT_VW wot_vw
    WHERE(wot_vw."Task ID" = wot."task_id") GROUP BY wot_rept_vw."Task ID") as "WO"
    from   TASK_TBL wot
    INNER JOIN
    (SELECT "name", MAX("task_version") AS MaxVersion from TASK_TBL
             GROUP BY "name") q
    ON (wot."name" = q."name" AND wot."task_version" = q.MaxVersion)
    order by NLSSORT(wot."name",'NLS_SORT=generic_m')
    Here this order by is causing problem
    Apex version is 4.0
    Thanks.
    Edited by: apex on Feb 21, 2012 7:24 PM

    'My car doesn't start, please help me to start my car'
    Do you think we are clairvoyant?
    Or is your salary subtracted for every letter you type here?
    Please be aware this is not a chatroom, and we can not see your webcam.
    Sybrand Bakker
    Senior Oracle DBA

  • CO41 taking more time to execute

    Hi,
    I am running CO41 (PRD System), but the time it is taking to execute is extensively high. Ultimately i have to kill the sesison to stop the process.
    What can be the probable reason for the same.
    My Inputs to CO41 are,
    Planning Plant
    MRP Controller
    Production Plant
    Kindly guide.
    Thanks in advance,
    Harris

    Dear,
    This is runtime problems occur during the conversion of planned orders it may be due to ATP check or may be due to  buffering of certain tables.
    In the check control (Transaction OPPJ), you can define the stocks, inward movements and outward movements that are considered.
    Below, you will find a list of database tables that are accessed, depending on the setting.
    Stocks:
    Storage locations:    MARD
    Sales order stocks:   MSSA
    Project stocks:       MSSQ
    Subcontracting:       MSSL
    Batches:              MCHB
    Customer consignment: MSSK
    Inward/outward movements:
    Purchase orders:             MDBS (view for EKPO and EKET)
    Production orders:           MDFA (view for AFPO)
    Purchase requisitions:       EBAN
    Dependent req., order res.:  MDRS (view for RESB)
    Manual reservations:         MDRS (view for RESB)
    Stock transfer reservations: MDUR (view for REUL and RESB)
    Sales requirements:          VBBE (individual records)
                                VBBS (totals records)
    Please use releavant setting for the ATP check.
    Also raise to OSS for same.
    Hope it will help you.
    Regards,
    R.Brahmankar

  • View query execution taking more time

    hi all,
    what would be the reason that my event view is still not getting executed for around 24 hours.
    actually i created 2 event views one is like ora1 and another is like ora1_1 both are having the same data.
    the first view ora1 executed by 14 hours.
    but my second view still not get executed it is still running for last 30 hours.
    very urgent.
    plz tell me the reason for the delay
    and if possible provide me a solution too
    thanks in advance
    suresh

    Dear sir,
    Please find the Scripts & Explain Plan for the Scripts in the attachment (ABC.zip)
    ABCReports51_new.sql - Fetching values from EVENT_T_VIEW
    ABCReports51_new_1.sql - Fetching values from EVENT_T
    create_event_view.sql - Command executed to create EVENT_T_VIEW
    ExplainPlan4event_t.txt - Explain Plan for the Query fetching values from event_t table
    ExplainPlan4event_t_view.txt - Explain Plan for the Query fetching values from event_t_view
    indexed_columns.txt - Indexed columns in event_t
    TableDesc.txt - Table description for event_t, event_bal_impacts_t, event_session_dialup_t
    SQL> desc event_bal_impacts_t;
    Name Null? Type
    OBJ_ID0 NUMBER(38)
    REC_ID NUMBER(38)
    ACCOUNT_OBJ_DB NUMBER(38)
    ACCOUNT_OBJ_ID0 NUMBER(38)
    ACCOUNT_OBJ_TYPE VARCHAR2(255)
    ACCOUNT_OBJ_REV NUMBER(38)
    AMOUNT NUMBER
    AMOUNT_DEFERRED NUMBER
    AMOUNT_ORIG NUMBER
    DISCOUNT NUMBER
    GL_ID NUMBER(38)
    IMPACT_CATEGORY VARCHAR2(255)
    IMPACT_TYPE NUMBER(38)
    ITEM_OBJ_DB NUMBER(38)
    ITEM_OBJ_ID0 NUMBER(38)
    ITEM_OBJ_TYPE VARCHAR2(255)
    ITEM_OBJ_REV NUMBER(38)
    PERCENT NUMBER
    PRODUCT_OBJ_DB NUMBER(38)
    PRODUCT_OBJ_ID0 NUMBER(38)
    PRODUCT_OBJ_TYPE VARCHAR2(255)
    PRODUCT_OBJ_REV NUMBER(38)
    QUANTITY NUMBER
    RATE_OBJ_DB NUMBER(38)
    RATE_OBJ_ID0 NUMBER(38)
    RATE_OBJ_TYPE VARCHAR2(255)
    RATE_OBJ_REV NUMBER(38)
    RATE_TAG VARCHAR2(255)
    RESOURCE_ID NUMBER(38)
    RESOURCE_ID_ORIG NUMBER(38)
    TAX_CODE VARCHAR2(255)
    NODE_LOCATION VARCHAR2(255)
    LINEAGE VARCHAR2(255)
    SQL> desc event_session_dialup_t;
    Name Null? Type
    OBJ_ID0 NUMBER(38)
    ANI VARCHAR2(120)
    BYTES_IN NUMBER(38)
    BYTES_OUT NUMBER(38)
    DESCR VARCHAR2(255)
    DNIS VARCHAR2(60)
    IPADDR RAW(30)
    LOGIN VARCHAR2(255)
    NETWORK VARCHAR2(30)
    PACKETS_IN NUMBER(38)
    PACKETS_OUT NUMBER(38)
    SPEED NUMBER(38)
    STATUS NUMBER(38)
    TERM_CAUSE NUMBER(38)
    TERMSERV_ID VARCHAR2(60)
    TERMSERV_PORT VARCHAR2(60)
    TIMEZONE NUMBER(38)
    TRANS_ID VARCHAR2(60)
    TYPE NUMBER(38)
    UNITS NUMBER(38)
    SQL> desc event_t;
    Name Null? Type
    POID_DB NUMBER(38)
    POID_ID0 NUMBER(38)
    POID_TYPE VARCHAR2(255)
    POID_REV NUMBER(38)
    CREATED_T NUMBER(38)
    MOD_T NUMBER(38)
    READ_ACCESS VARCHAR2(1)
    WRITE_ACCESS VARCHAR2(1)
    ACCOUNT_OBJ_DB NUMBER(38)
    ACCOUNT_OBJ_ID0 NUMBER(38)
    ACCOUNT_OBJ_TYPE VARCHAR2(255)
    ACCOUNT_OBJ_REV NUMBER(38)
    ARCHIVE_STATUS NUMBER(38)
    CURRENCY NUMBER(38)
    DESCR VARCHAR2(255)
    EFFECTIVE_T NUMBER(38)
    END_T NUMBER(38)
    EARNED_START_T NUMBER(38)
    EARNED_END_T NUMBER(38)
    EARNED_TYPE NUMBER(38)
    EVENT_NO VARCHAR2(60)
    FLAGS NUMBER(38)
    GROUP_OBJ_DB NUMBER(38)
    GROUP_OBJ_ID0 NUMBER(38)
    GROUP_OBJ_TYPE VARCHAR2(255)
    GROUP_OBJ_REV NUMBER(38)
    ITEM_OBJ_DB NUMBER(38)
    ITEM_OBJ_ID0 NUMBER(38)
    ITEM_OBJ_TYPE VARCHAR2(255)
    ITEM_OBJ_REV NUMBER(38)
    NAME VARCHAR2(255)
    PROGRAM_NAME VARCHAR2(60)
    PROVIDER_DESCR VARCHAR2(255)
    PROVIDER_ID_DB NUMBER(38)
    PROVIDER_ID_ID0 NUMBER(38)
    PROVIDER_ID_TYPE VARCHAR2(255)
    PROVIDER_ID_REV NUMBER(38)
    PROVIDER_IPADDR RAW(30)
    RUM_NAME VARCHAR2(255)
    TOD_MODE NUMBER(38)
    TIMEZONE_MODE NUMBER(38)
    MIN_QUANTITY NUMBER
    MIN_UNIT NUMBER(38)
    INCR_QUANTITY NUMBER
    INCR_UNIT NUMBER(38)
    ROUNDING_MODE NUMBER(38)
    NET_QUANTITY NUMBER
    UNRATED_QUANTITY NUMBER
    SERVICE_OBJ_DB NUMBER(38)
    SERVICE_OBJ_ID0 NUMBER(38)
    SERVICE_OBJ_TYPE VARCHAR2(255)
    SERVICE_OBJ_REV NUMBER(38)
    SESSION_OBJ_DB NUMBER(38)
    SESSION_OBJ_ID0 NUMBER(38)
    SESSION_OBJ_TYPE VARCHAR2(255)
    SESSION_OBJ_REV NUMBER(38)
    START_T NUMBER(38)
    SYS_DESCR VARCHAR2(255)
    TAX_LOCALES VARCHAR2(1024)
    TAX_SUPPLIER_ID_DB NUMBER(38)
    TAX_SUPPLIER_ID_ID0 NUMBER(38)
    TAX_SUPPLIER_ID_TYPE VARCHAR2(255)
    TAX_SUPPLIER_ID_REV NUMBER(38)
    USERID_DB NUMBER(38)
    USERID_ID0 NUMBER(38)
    USERID_TYPE VARCHAR2(255)
    USERID_REV NUMBER(38)
    INVOICE_DATA VARCHAR2(4000)
    RATED_TIMEZONE_ID VARCHAR2(64)
    TIMEZONE_ADJ_START_T NUMBER(38)
    TIMEZONE_ADJ_END_T NUMBER(38)
    TIMEZONE_ID VARCHAR2(64)
    UNIT NUMBER(38)
    RERATE_OBJ_DB NUMBER(38)
    RERATE_OBJ_ID0 NUMBER(38)
    RERATE_OBJ_TYPE VARCHAR2(255)
    RERATE_OBJ_REV NUMBER(38)
    select index_name, column_name, column_position from all_ind_columns where table_name like upper('event_t')
    INDEX_NAME COLUMN_NAME COLUMN_POSITION
    I_EVENT_CREATED_T CREATED_T 1
    I_EVENT_EVENT__NO EVENT_NO 1
    I_EVENT_ITEM_OBJ__ID ITEM_OBJ_ID0 1
    I_EVENT_NDX CREATED_T 1
    I_EVENT_NDX POID_ID0 2
    I_EVENT_PROVIDER__ID PROVIDER_ID_ID0 1
    I_EVENT__ACCTOBJ_END_T ACCOUNT_OBJ_ID0 1
    I_EVENT__ACCTOBJ_END_T END_T 2
    I_EVENT__END_T END_T 1
    I_EVENT__ID POID_ID0 1
    I_EVENT__SERVOBJ_END_T SERVICE_OBJ_ID0 1
    I_EVENT__SERVOBJ_END_T END_T 2
    explain plan for select 'Technical Building' PopName, sum(end_t - start_t) UsageSec, avg(end_t - start_t) AvgSec
    from event_bal_impacts_t c, event_session_dialup_t b, event_t_view a
    where
    end_t between date2unix(20060101000000) and date2unix(20060501000000) and
    b.obj_id0 = a.poid_id0 and
    c.obj_id0 = a.poid_id0 and
    c.rec_id = 0 and
    a.service_obj_type = '/service/ip' and
    a.poid_type = '/event/session/dialup' and
    b.termserv_id in ('62.231.255.21','62.231.255.22','62.231.255.23','62.231.255.24','62.231.255.25','62.231.255.26','62.231.255.27','62.231.255.28','62.231.255.29','62.231.255.30','62.231.255.31','62.231.255.32','62.231.255.33','62.231.255.34','62.231.255.35','62.231.255.36','62.231.255.37','62.231.255.38','62.231.255.39','62.231.255.40','62.231.255.43','62.231.255.44','62.231.255.255','ADSL-7301-Test','AKO2_ERX700','AZA1_ERX700','GHA1_ERX700','GMU4_ERX700','HMR1_ERX700','HMSQ_ERX700','KWR1_ERX700','MUS','MUS1_ERX700','MUT','MUT1_ERX700','MUTRAH-ERX','OMAN-ADSL-Test','QUR2_ERX700','Qur','SEB2_ERX700','TECH_BLDG','WAT1_ERX700','WKB1_ERX700','azaiba','TB-C10K-ADSL') and
    c.product_obj_id0 not in
    select poid_id0 from product_t
    where name like '%Cyber%'
    select
    substr (lpad(' ', level-1) || operation || ' (' || options || ')',1,30 ) "Operation",
    object_name "Object",
    partition_start, partition_stop
    from
    plan_table
    start with id = 0
    connect by prior id=parent_id;
    Operation Object PARTITION_START PARTITION_STOP
    SELECT STATEMENT ()
    SORT (AGGREGATE)
    FILTER ()
    NESTED LOOPS ()
    NESTED LOOPS ()
    PARTITION RANGE (ALL) 1 41
    TABLE ACCESS (BY LOCAL I EVENT_T 1 41
    INDEX (RANGE SCAN) I_EVENT__END_T 1 41
    PARTITION RANGE (ITERATOR KEY KEY
    TABLE ACCESS (BY LOCAL I EVENT_BAL_IMPACTS_T KEY KEY
    INDEX (RANGE SCAN) I_EVENT_BAL_IMPACTS__ID KEY KEY
    PARTITION RANGE (ITERATOR) KEY KEY
    TABLE ACCESS (BY LOCAL IN EVENT_SESSION_DIALUP_T KEY KEY
    INDEX (UNIQUE SCAN) I_EVENT_SESSION_DIALUP__ID KEY KEY
    TABLE ACCESS (FULL) PRODUCT_T
    explain plan for select 'Technical Building' PopName, sum(end_t - start_t) UsageSec, avg(end_t - start_t) AvgSec
    from event_bal_impacts_t c, event_session_dialup_t b, event_t a
    where
    end_t between date2unix(20060101000000) and date2unix(20060501000000) and
    b.obj_id0 = a.poid_id0 and
    c.obj_id0 = a.poid_id0 and
    c.rec_id = 0 and
    a.service_obj_type = '/service/ip' and
    a.poid_type = '/event/session/dialup' and
    b.termserv_id in ('62.231.255.21','62.231.255.22','62.231.255.23','62.231.255.24','62.231.255.25','62.231.255.26','62.231.255.27','62.231.255.28','62.231.255.29','62.231.255.30','62.231.255.31','62.231.255.32','62.231.255.33','62.231.255.34','62.231.255.35','62.231.255.36','62.231.255.37','62.231.255.38','62.231.255.39','62.231.255.40','62.231.255.43','62.231.255.44','62.231.255.255','ADSL-7301-Test','AKO2_ERX700','AZA1_ERX700','GHA1_ERX700','GMU4_ERX700','HMR1_ERX700','HMSQ_ERX700','KWR1_ERX700','MUS','MUS1_ERX700','MUT','MUT1_ERX700','MUTRAH-ERX','OMAN-ADSL-Test','QUR2_ERX700','Qur','SEB2_ERX700','TECH_BLDG','WAT1_ERX700','WKB1_ERX700','azaiba','TB-C10K-ADSL') and
    c.product_obj_id0 not in
    select poid_id0 from product_t
    where name like '%Cyber%'
    select
    substr (lpad(' ', level-1) || operation || ' (' || options || ')',1,30 ) "Operation",
    object_name "Object",
    partition_start, partition_stop
    from
    plan_table
    start with id = 0
    connect by prior id=parent_id;
    Operation Object PARTITION_START PARTITION_STOP
    SELECT STATEMENT ()
    SORT (AGGREGATE)
    FILTER ()
    NESTED LOOPS ()
    NESTED LOOPS ()
    PARTITION RANGE (ALL) 1 41
    TABLE ACCESS (BY LOCAL I EVENT_T 1 41
    INDEX (RANGE SCAN) I_EVENT__END_T 1 41
    PARTITION RANGE (ITERATOR KEY KEY
    TABLE ACCESS (BY LOCAL I EVENT_BAL_IMPACTS_T KEY KEY
    INDEX (RANGE SCAN) I_EVENT_BAL_IMPACTS__ID KEY KEY
    PARTITION RANGE (ITERATOR) KEY KEY
    TABLE ACCESS (BY LOCAL IN EVENT_SESSION_DIALUP_T KEY KEY
    INDEX (UNIQUE SCAN) I_EVENT_SESSION_DIALUP__ID KEY KEY
    TABLE ACCESS (FULL) PRODUCT_T
    spool create_event_view.lst
    set timing on
    create view event_t_view as (select * from event_t where end_t between date2unix('20060701000000') and date2unix('20061001000000'))
    spool off
    set serveroutput on size 1000000
    set timing on
    set linesize 132
    spool ABCReports51_new_1.lst
    declare
    m_report_year number(8);
    v_start varchar(38);
    v_end varchar(38);
    -- Fetch all Session Events for Non CyberCafe (Only IP Service) Product Events
    cursor SessionUsagePOP1(v_start varchar, v_end varchar) is
    select 'Technical Building' PopName, sum(end_t - start_t) UsageSec, avg(end_t - start_t) AvgSec
    from event_bal_impacts_t c, event_session_dialup_t b, event_t a
    where
    end_t between date2unix(v_start) and date2unix(v_end) and
    b.obj_id0 = a.poid_id0 and
    c.obj_id0 = a.poid_id0 and
    c.rec_id = 0 and
    a.service_obj_type = '/service/ip' and
    a.poid_type = '/event/session/dialup' and
    b.termserv_id in ('62.231.255.21','62.231.255.22','62.231.255.23','62.231.255.24','62.231.255.25','62.231.255.26','62.231.255.27','62.231.255.28','62.231.255.29','62.231.255.30','62.231.255.31','62.231.255.32','62.231.255.33','62.231.255.34','62.231.255.35','62.231.255.36','62.231.255.37','62.231.255.38','62.231.255.39','62.231.255.40','62.231.255.43','62.231.255.44','62.231.255.255','ADSL-7301-Test','AKO2_ERX700','AZA1_ERX700','GHA1_ERX700','GMU4_ERX700','HMR1_ERX700','HMSQ_ERX700','KWR1_ERX700','MUS','MUS1_ERX700','MUT','MUT1_ERX700','MUTRAH-ERX','OMAN-ADSL-Test','QUR2_ERX700','Qur','SEB2_ERX700','TECH_BLDG','WAT1_ERX700','WKB1_ERX700','azaiba','TB-C10K-ADSL') and
    c.product_obj_id0 not in
    select poid_id0 from product_t
    where name like '%Cyber%'
    cursor SessionUsagePOP2(v_start varchar, v_end varchar) is
    select 'Training Center' PopName, sum(end_t - start_t) UsageSec, avg(end_t - start_t) AvgSec
    from event_bal_impacts_t c, event_session_dialup_t b, event_t a
    where
    end_t between date2unix(v_start) and date2unix(v_end) and
    b.obj_id0 = a.poid_id0 and
    c.obj_id0 = a.poid_id0 and
    c.rec_id = 0 and
    a.service_obj_type = '/service/ip' and
    a.poid_type = '/event/session/dialup' and
    b.termserv_id in ('62.231.255.224','62.231.255.225','62.231.255.226','62.231.255.227','62.231.255.228','TRG-10K-ADSL') and
    c.product_obj_id0 not in
    select poid_id0 from product_t
    where name like '%Cyber%'
    cursor SessionUsagePOP3(v_start varchar, v_end varchar) is
    select 'Al-Khuwair' PopName, sum(end_t - start_t) UsageSec, avg(end_t - start_t) AvgSec
    from event_bal_impacts_t c, event_session_dialup_t b, event_t a
    where
    end_t between date2unix(v_start) and date2unix(v_end) and
    b.obj_id0 = a.poid_id0 and
    c.obj_id0 = a.poid_id0 and
    c.rec_id = 0 and
    a.service_obj_type = '/service/ip' and
    a.poid_type = '/event/session/dialup' and
    b.termserv_id in ('62.231.255.208') and
    c.product_obj_id0 not in
    select poid_id0 from product_t
    where name like '%Cyber%'
    cursor SessionUsagePOP4(v_start varchar, v_end varchar) is
    select 'Sallalah' PopName, sum(end_t - start_t) UsageSec, avg(end_t - start_t) AvgSec
    from event_bal_impacts_t c, event_session_dialup_t b, event_t a
    where
    end_t between date2unix(v_start) and date2unix(v_end) and
    b.obj_id0 = a.poid_id0 and
    c.obj_id0 = a.poid_id0 and
    c.rec_id = 0 and
    a.service_obj_type = '/service/ip' and
    a.poid_type = '/event/session/dialup' and
    b.termserv_id in ('62.231.192.20','62.231.192.21','62.231.192.22','62.231.255.132','62.231.255.133','62.231.255.134','SAL-10K-ADSL') and
    c.product_obj_id0 not in
    select poid_id0 from product_t
    where name like '%Cyber%'
    cursor SessionUsagePOP5(v_start varchar, v_end varchar) is
    select 'Sohar' PopName, sum(end_t - start_t) UsageSec, avg(end_t - start_t) AvgSec
    from event_bal_impacts_t c, event_session_dialup_t b, event_t a
    where
    end_t between date2unix(v_start) and date2unix(v_end) and
    b.obj_id0 = a.poid_id0 and
    c.obj_id0 = a.poid_id0 and
    c.rec_id = 0 and
    a.service_obj_type = '/service/ip' and
    a.poid_type = '/event/session/dialup' and
    b.termserv_id in ('62.231.200.20','62.231.200.21','62.231.255.148','62.231.255.149','SOH-10K-ADSL') and
    c.product_obj_id0 not in
    select poid_id0 from product_t
    where name like '%Cyber%'
    cursor SessionUsagePOP6(v_start varchar, v_end varchar) is
    select 'Nizwa' PopName, sum(end_t - start_t) UsageSec, avg(end_t - start_t) AvgSec
    from event_bal_impacts_t c, event_session_dialup_t b, event_t a
    where
    end_t between date2unix(v_start) and date2unix(v_end) and
    b.obj_id0 = a.poid_id0 and
    c.obj_id0 = a.poid_id0 and
    c.rec_id = 0 and
    a.service_obj_type = '/service/ip' and
    a.poid_type = '/event/session/dialup' and
    b.termserv_id in ('62.231.216.20','62.231.255.180','62.231.255.181','NIZ-10K-ADSL') and
    c.product_obj_id0 not in
    select poid_id0 from product_t
    where name like '%Cyber%'
    cursor SessionUsagePOP7(v_start varchar, v_end varchar) is
    select 'Masirah' PopName, sum(end_t - start_t) UsageSec, avg(end_t - start_t) AvgSec
    from event_bal_impacts_t c, event_session_dialup_t b, event_t a
    where
    end_t between date2unix(v_start) and date2unix(v_end) and
    b.obj_id0 = a.poid_id0 and
    c.obj_id0 = a.poid_id0 and
    c.rec_id = 0 and
    a.service_obj_type = '/service/ip' and
    a.poid_type = '/event/session/dialup' and
    b.termserv_id in ('212.72.13.41') and
    c.product_obj_id0 not in
    select poid_id0 from product_t
    where name like '%Cyber%'
    cursor SessionUsagePOP8(v_start varchar, v_end varchar) is
    select 'Ibri' PopName, sum(end_t - start_t) UsageSec, avg(end_t - start_t) AvgSec
    from event_bal_impacts_t c, event_session_dialup_t b, event_t a
    where
    end_t between date2unix(v_start) and date2unix(v_end) and
    b.obj_id0 = a.poid_id0 and
    c.obj_id0 = a.poid_id0 and
    c.rec_id = 0 and
    a.service_obj_type = '/service/ip' and
    a.poid_type = '/event/session/dialup' and
    b.termserv_id in ('62.231.224.20') and
    c.product_obj_id0 not in
    select poid_id0 from product_t
    where name like '%Cyber%'
    cursor SessionUsagePOP9(v_start varchar, v_end varchar) is
    select 'Sur' PopName, sum(end_t - start_t) UsageSec, avg(end_t - start_t) AvgSec
    from event_bal_impacts_t c, event_session_dialup_t b, event_t a
    where
    end_t between date2unix(v_start) and date2unix(v_end) and
    b.obj_id0 = a.poid_id0 and
    c.obj_id0 = a.poid_id0 and
    c.rec_id = 0 and
    a.service_obj_type = '/service/ip' and
    a.poid_type = '/event/session/dialup' and
    b.termserv_id in ('62.231.255.164','SUR-10K-ADSL') and
    c.product_obj_id0 not in
    select poid_id0 from product_t
    where name like '%Cyber%'
    cursor SessionUsagePOP10(v_start varchar, v_end varchar) is
    select 'Buraimi' PopName, sum(end_t - start_t) UsageSec, avg(end_t - start_t) AvgSec
    from event_bal_impacts_t c, event_session_dialup_t b, event_t a
    where
    end_t between date2unix(v_start) and date2unix(v_end) and
    b.obj_id0 = a.poid_id0 and
    c.obj_id0 = a.poid_id0 and
    c.rec_id = 0 and
    a.service_obj_type = '/service/ip' and
    a.poid_type = '/event/session/dialup' and
    b.termserv_id in ('BR-10K-ADSL') and
    c.product_obj_id0 not in
    select poid_id0 from product_t
    where name like '%Cyber%'
    begin
    m_report_year := 2006;
    v_start:='20060701000000';
    v_end:='20061001000000';
    /** Dialup Accounts Usage on each month **/
    dbms_output.put_line('Dialup Accounts Usage on each month during the Year ' || m_report_year);
    dbms_output.put_line('POP Name MM-YYYY No. of Seconds Avg. No. of Seconds');
    for c1 in 7..9
    loop <<c1_loop>>
    for c11 in SessionUsagePOP1(
    m_report_year || lpad(c1, 2, '0') || '01000000',
    m_report_year || lpad(c1 + 1, 2, '0') || '01000000'
    loop <<c11_loop>>
    dbms_output.put_line(
    rpad(c11.PopName,25, ' ') || ' ' ||
    to_char(c1, '00') || '-' ||
    m_report_year || ' ' ||
    to_char(c11.UsageSec,'999,999,999,999') || ' ' ||
    to_char(c11.AvgSec,'999,999,999.999')
    end loop c11_loop;
    end loop c1_loop;
    for c1 in 7..9
    loop <<c1_loop>>
    for c11 in SessionUsagePOP2(
    m_report_year || lpad(c1, 2, '0') || '01000000',
    m_report_year || lpad(c1 + 1, 2, '0') || '01000000'
    loop <<c11_loop>>
    dbms_output.put_line(
    rpad(c11.PopName,25, ' ') || ' ' ||
    to_char(c1, '00') || '-' ||
    m_report_year || ' ' ||
    to_char(c11.UsageSec,'999,999,999,999') || ' ' ||
    to_char(c11.AvgSec,'999,999,999.999')
    end loop c11_loop;
    end loop c1_loop;
    for c1 in 7..9
    loop <<c1_loop>>
    for c11 in SessionUsagePOP3(
    m_report_year || lpad(c1, 2, '0') || '01000000',
    m_report_year || lpad(c1 + 1, 2, '0') || '01000000'
    loop <<c11_loop>>
    dbms_output.put_line(
    rpad(c11.PopName,25, ' ') || ' ' ||
    to_char(c1, '00') || '-' ||
    m_report_year || ' ' ||
    to_char(c11.UsageSec,'999,999,999,999') || ' ' ||
    to_char(c11.AvgSec,'999,999,999.999')
    end loop c11_loop;
    end loop c1_loop;
    for c1 in 7..9
    loop <<c1_loop>>
    for c11 in SessionUsagePOP4(
    m_report_year || lpad(c1, 2, '0') || '01000000',
    m_report_year || lpad(c1 + 1, 2, '0') || '01000000'
    loop <<c11_loop>>
    dbms_output.put_line(
    rpad(c11.PopName,25, ' ') || ' ' ||
    to_char(c1, '00') || '-' ||
    m_report_year || ' ' ||
    to_char(c11.UsageSec,'999,999,999,999') || ' ' ||
    to_char(c11.AvgSec,'999,999,999.999')
    end loop c11_loop;
    end loop c1_loop;
    for c1 in 7..9
    loop <<c1_loop>>
    for c11 in SessionUsagePOP5(
    m_report_year || lpad(c1, 2, '0') || '01000000',
    m_report_year || lpad(c1 + 1, 2, '0') || '01000000'
    loop <<c11_loop>>
    dbms_output.put_line(
    rpad(c11.PopName,25, ' ') || ' ' ||
    to_char(c1, '00') || '-' ||
    m_report_year || ' ' ||
    to_char(c11.UsageSec,'999,999,999,999') || ' ' ||
    to_char(c11.AvgSec,'999,999,999.999')
    end loop c11_loop;
    end loop c1_loop;
    for c1 in 7..9
    loop <<c1_loop>>
    for c11 in SessionUsagePOP6(
    m_report_year || lpad(c1, 2, '0') || '01000000',
    m_report_year || lpad(c1 + 1, 2, '0') || '01000000'
    loop <<c11_loop>>
    dbms_output.put_line(
    rpad(c11.PopName,25, ' ') || ' ' ||
    to_char(c1, '00') || '-' ||
    m_report_year || ' ' ||
    to_char(c11.UsageSec,'999,999,999,999') || ' ' ||
    to_char(c11.AvgSec,'999,999,999.999')
    end loop c11_loop;
    end loop c1_loop;
    for c1 in 7..9
    loop <<c1_loop>>
    for c11 in SessionUsagePOP7(
    m_report_year || lpad(c1, 2, '0') || '01000000',
    m_report_year || lpad(c1 + 1, 2, '0') || '01000000'
    loop <<c11_loop>>
    dbms_output.put_line(
    rpad(c11.PopName,25, ' ') || ' ' ||
    to_char(c1, '00') || '-' ||
    m_report_year || ' ' ||
    to_char(c11.UsageSec,'999,999,999,999') || ' ' ||
    to_char(c11.AvgSec,'999,999,999.999')
    end loop c11_loop;
    end loop c1_loop;
    for c1 in 7..9
    loop <<c1_loop>>
    for c11 in SessionUsagePOP8(
    m_report_year || lpad(c1, 2, '0') || '01000000',
    m_report_year || lpad(c1 + 1, 2, '0') || '01000000'
    loop <<c11_loop>>
    dbms_output.put_line(
    rpad(c11.PopName,25, ' ') || ' ' ||
    to_char(c1, '00') || '-' ||
    m_report_year || ' ' ||
    to_char(c11.UsageSec,'999,999,999,999') || ' ' ||
    to_char(c11.AvgSec,'999,999,999.999')
    end loop c11_loop;
    end loop c1_loop;
    for c1 in 7..9
    loop <<c1_loop>>
    for c11 in SessionUsagePOP9(
    m_report_year || lpad(c1, 2, '0') || '01000000',
    m_report_year || lpad(c1 + 1, 2, '0') || '01000000'
    loop <<c11_loop>>
    dbms_output.put_line(
    rpad(c11.PopName,25, ' ') || ' ' ||
    to_char(c1, '00') || '-' ||
    m_report_year || ' ' ||
    to_char(c11.UsageSec,'999,999,999,999') || ' ' ||
    to_char(c11.AvgSec,'999,999,999.999')
    end loop c11_loop;
    end loop c1_loop;
    for c1 in 7..9
    loop <<c1_loop>>
    for c11 in SessionUsagePOP10(
    m_report_year || lpad(c1, 2, '0') || '01000000',
    m_report_year || lpad(c1 + 1, 2, '0') || '01000000'
    loop <<c11_loop>>
    dbms_output.put_line(
    rpad(c11.PopName,25, ' ') || ' ' ||
    to_char(c1, '00') || '-' ||
    m_report_year || ' ' ||
    to_char(c11.UsageSec,'999,999,999,999') || ' ' ||
    to_char(c11.AvgSec,'999,999,999.999')
    end loop c11_loop;
    end loop c1_loop;
    end;
    spool off
    Dialup Accounts Usage on each month during the Year 2006
    POP Name MM-YYYY No. of Seconds Avg. No. of Seconds
    Technical Building 07-2006 1,468,439,634 1,985.848
    Technical Building 08-2006 1,476,030,818 1,954.927
    Technical Building 09-2006 1,385,143,427 1,917.764
    Training Center 07-2006 19,481,275 2,193.343
    Training Center 08-2006 7,368,849 2,317.977
    Training Center 09-2006
    Al-Khuwair 07-2006 327,753,498 1,929.392
    Al-Khuwair 08-2006 326,043,930 1,867.751
    Al-Khuwair 09-2006 314,307,853 1,884.758
    Sallalah 07-2006 297,238,088 2,127.765
    Sallalah 08-2006 291,646,501 2,049.130
    Sallalah 09-2006 256,812,968 2,050.403
    Sohar 07-2006 499,669,759 2,002.588
    Sohar 08-2006 517,602,784 1,996.208
    Sohar 09-2006 460,677,766 1,965.760
    Nizwa 07-2006 313,445,474 1,804.896
    Nizwa 08-2006 336,749,026 1,820.708
    Nizwa 09-2006 279,534,466 1,809.074
    Masirah 07-2006 17,417,301 2,315.822
    Masirah 08-2006 20,053,961 2,791.087
    Masirah 09-2006 17,225,347 2,656.593
    Ibri 07-2006
    Ibri 08-2006
    Ibri 09-2006
    Sur 07-2006 146,555,060 1,765.681
    Sur 08-2006 148,694,745 1,710.157
    Sur 09-2006 138,260,990 1,687.962
    Buraimi 07-2006
    Buraimi 08-2006
    Buraimi 09-2006
    PL/SQL procedure successfully completed.
    Elapsed: 14:27:26.17
    set serveroutput on size 1000000
    set timing on
    set linesize 132
    spool ABCReports51_new.lst
    declare
    m_report_year number(8);
    v_start varchar(38);
    v_end varchar(38);
    -- Fetch all Session Events for Non CyberCafe (Only IP Service) Product Events
    cursor SessionUsagePOP1(v_start varchar, v_end varchar) is
    select 'Technical Building' PopName, sum(end_t - start_t) UsageSec, avg(end_t - start_t) AvgSec
    from event_bal_impacts_t c, event_session_dialup_t b, event_t_view a
    where
    end_t between date2unix(v_start) and date2unix(v_end) and
    b.obj_id0 = a.poid_id0 and
    c.obj_id0 = a.poid_id0 and
    c.rec_id = 0 and
    a.service_obj_type = '/service/ip' and
    a.poid_type = '/event/session/dialup' and
    b.termserv_id in ('62.231.255.21','62.231.255.22','62.231.255.23','62.231.255.24','62.231.255.25','62.231.255.26','62.231.255.27','62.231.255.28','62.231.255.29','62.231.255.30','62.231.255.31','62.231.255.32','62.231.255.33','62.231.255.34','62.231.255.35','62.231.255.36','62.231.255.37','62.231.255.38','62.231.255.39','62.231.255.40','62.231.255.43','62.231.255.44','62.231.255.255','ADSL-7301-Test','AKO2_ERX700','AZA1_ERX700','GHA1_ERX700','GMU4_ERX700','HMR1_ERX700','HMSQ_ERX700','KWR1_ERX700','MUS','MUS1_ERX700','MUT','MUT1_ERX700','MUTRAH-ERX','OMAN-ADSL-Test','QUR2_ERX700','Qur','SEB2_ERX700','TECH_BLDG','WAT1_ERX700','WKB1_ERX700','azaiba','TB-C10K-ADSL') and
    c.product_obj_id0 not in
    select poid_id0 from product_t
    where name like '%Cyber%'
    cursor SessionUsagePOP2(v_start varchar, v_end varchar) is
    select 'Training Center' PopName, sum(end_t - start_t) UsageSec, avg(end_t - start_t) AvgSec
    from event_bal_impacts_t c, event_session_dialup_t b, event_t_view a
    where
    end_t between date2unix(v_start) and date2unix(v_end) and
    b.obj_id0 = a.poid_id0 and
    c.obj_id0 = a.poid_id0 and
    c.rec_id = 0 and
    a.service_obj_type = '/service/ip' and
    a.poid_type = '/event/session/dialup' and
    b.termserv_id in ('62.231.255.224','62.231.255.225','62.231.255.226','62.231.255.227','62.231.255.228','TRG-10K-ADSL') and
    c.product_obj_id0 not in
    select poid_id0 from product_t
    where name like '%Cyber%'
    cursor SessionUsagePOP3(v_start varchar, v_end varchar) is
    select 'Al-Khuwair' PopName, sum(end_t - start_t) UsageSec, avg(end_t - start_t) AvgSec
    from event_bal_impacts_t c, event_session_dialup_t b, event_t_view a
    where
    end_t between date2unix(v_start) and date2unix(v_end) and
    b.obj_id0 = a.poid_id0 and
    c.obj_id0 = a.poid_id0 and
    c.rec_id = 0 and
    a.service_obj_type = '/service/ip' and
    a.poid_type = '/event/session/dialup' and
    b.termserv_id in ('62.231.255.208') and
    c.product_obj_id0 not in
    select poid_id0 from product_t
    where name like '%Cyber%'
    cursor SessionUsagePOP4(v_start varchar, v_end varchar) is
    select 'Sallalah' PopName, sum(end_t - start_t) UsageSec, avg(end_t - start_t) AvgSec
    from event_bal_impacts_t c, event_session_dialup_t b, event_t_view a
    where
    end_t between date2unix(v_start) and date2unix(v_end) and
    b.obj_id0 = a.poid_id0 and
    c.obj_id0 = a.poid_id0 and
    c.rec_id = 0 and
    a.service_obj_type = '/service/ip' and
    a.poid_type = '/event/session/dialup' and
    b.termserv_id in ('62.231.192.20','62.231.192.21','62.231.192.22','62.231.255.132','62.231.255.133','62.231.255.134','SAL-10K-ADSL') and
    c.product_obj_id0 not in
    select poid_id0 from product_t
    where name like '%Cyber%'
    cursor SessionUsagePOP5(v_start varchar, v_end varchar) is
    select 'Sohar' PopName, sum(end_t - start_t) UsageSec, avg(end_t - start_t) AvgSec
    from event_bal_impacts_t c, event_session_dialup_t b, event_t_view a
    where
    end_t between date2unix(v_start) and date2unix(v_end) and
    b.obj_id0 = a.poid_id0 and
    c.obj_id0 = a.poid_id0 and
    c.rec_id = 0 and
    a.service_obj_type = '/service/ip' and
    a.poid_type = '/event/session/dialup' and
    b.termserv_id in ('62.231.200.20','62.231.200.21','62.231.255.148','62.231.255.149','SOH-10K-ADSL') and
    c.product_obj_id0 not in
    select poid_id0 from product_t
    where name like '%Cyber%'
    cursor SessionUsagePOP6(v_start varchar, v_end varchar) is
    select 'Nizwa' PopName, sum(end_t - start_t) UsageSec, avg(end_t - start_t) AvgSec
    from event_bal_impacts_t c, event_session_dialup_t b, event_t_view a
    where
    end_t between date2unix(v_start) and date2unix(v_end) and
    b.obj_id0 = a.poid_id0 and
    c.obj_id0 = a.poid_id0 and
    c.rec_id = 0 and
    a.service_obj_type = '/service/ip' and
    a.poid_type = '/event/session/dialup' and
    b.termserv_id in ('62.231.216.20','62.231.255.180','62.231.255.181','NIZ-10K-ADSL') and
    c.product_obj_id0 not in
    select poid_id0 from product_t
    where name like '%Cyber%'
    cursor SessionUsagePOP7(v_start varchar, v_end varchar) is
    select 'Masirah' PopName, sum(end_t - start_t) UsageSec, avg(end_t - start_t) AvgSec
    from event_bal_impacts_t c, event_session_dialup_t b, event_t_view a
    where
    end_t between date2unix(v_start) and date2unix(v_end) and
    b.obj_id0 = a.poid_id0 and
    c.obj_id0 = a.poid_id0 and
    c.rec_id = 0 and
    a.service_obj_type = '/service/ip' and
    a.poid_type = '/event/session/dialup' and
    b.termserv_id in ('212.72.13.41') and
    c.product_obj_id0 not in
    select poid_id0 from product_t
    where name like '%Cyber%'
    cursor SessionUsagePOP8(v_start varchar, v_end varchar) is
    select 'Ibri' PopName, sum(end_t - start_t) UsageSec, avg(end_t - start_t) AvgSec
    from event_bal_impacts_t c, event_session_dialup_t b, event_t_view a
    where
    end_t between date2unix(v_start) and date2unix(v_end) and
    b.obj_id0 = a.poid_id0 and
    c.obj_id0 = a.poid_id0 and
    c.rec_id = 0 and
    a.service_obj_type = '/service/ip' and
    a.poid_type = '/event/session/dialup' and
    b.termserv_id in ('62.231.224.20') and
    c.product_obj_id0 not in
    select poid_id0 from product_t
    where name like '%Cyber%'
    cursor SessionUsagePOP9(v_start varchar, v_end varchar) is
    select 'Sur' PopName, sum(end_t - start_t) UsageSec, avg(end_t - start_t) AvgSec
    from event_bal_impacts_t c, event_session_dialup_t b, event_t_view a
    where
    end_t between date2unix(v_start) and date2unix(v_end) and
    b.obj_id0 = a.poid_id0 and
    c.obj_id0 = a.poid_id0 and
    c.rec_id = 0 and
    a.service_obj_type = '/service/ip' and
    a.poid_type = '/event/session/dialup' and
    b.termserv_id in ('62.231.255.164','SUR-10K-ADSL') and
    c.product_obj_id0 not in
    select poid_id0 from product_t
    where name like '%Cyber%'
    cursor SessionUsagePOP10(v_start varchar, v_end varchar) is
    select 'Buraimi' PopName, sum(end_t - start_t) UsageSec, avg(end_t - start_t) AvgSec
    from event_bal_impacts_t c, event_session_dialup_t b, event_t_view a
    where
    end_t between date2unix(v_start) and date2unix(v_end) and
    b.obj_id0 = a.poid_id0 and
    c.obj_id0 = a.poid_id0 and
    c.rec_id = 0 and
    a.service_obj_type = '/service/ip' and
    a.poid_type = '/event/session/dialup' and
    b.termserv_id in ('BR-10K-ADSL') and
    c.product_obj_id0 not in
    select poid_id0 from product_t
    where name like '%Cyber%'
    begin
    m_report_year := 2006;
    v_start:='20060701000000';
    v_end:='20061001000000';
    /** Dialup Accounts Usage on each month **/
    dbms_output.put_line('Dialup Accounts Usage on each month during the Year ' || m_report_year);
    dbms_output.put_line('POP Name MM-YYYY No. of Seconds Avg. No. of Seconds');
    for c1 in 7..9
    loop <<c1_loop>>
    for c11 in SessionUsagePOP1(
    m_report_year || lpad(c1, 2, '0') || '01000000',
    m_report_year || lpad(c1 + 1, 2, '0') || '01000000'
    loop <<c11_loop>>
    dbms_output.put_line(
    rpad(c11.PopName,25, ' ') || ' ' ||
    to_char(c1, '00') || '-' ||
    m_report_year || ' ' ||
    to_char(c11.UsageSec,'999,999,999,999') || ' ' ||
    to_char(c11.AvgSec,'999,999,999.999')
    end loop c11_loop;
    end loop c1_loop;
    for c1 in 7..9
    loop <<c1_loop>>
    for c11 in SessionUsagePOP2(
    m_report_year || lpad(c1, 2, '0') || '01000000',
    m_report_year || lpad(c1 + 1, 2, '0') || '01000000'
    loop <<c11_loop>>
    dbms_output.put_line(
    rpad(c11.PopName,25, ' ') || ' ' ||
    to_char(c1, '00') || '-' ||
    m_report_year || ' ' ||
    to_char(c11.UsageSec,'999,999,999,999') || ' ' ||
    to_char(c11.AvgSec,'999,999,999.999')
    end loop c11_loop;
    end loop c1_loop;
    for c1 in 7..9
    loop <<c1_loop>>
    for c11 in SessionUsagePOP3(
    m_report_year || lpad(c1, 2, '0') || '01000000',
    m_report_year || lpad(c1 + 1, 2, '0') || '01000000'
    loop <<c11_loop>>
    dbms_output.put_line(
    rpad(c11.PopName,25, ' ') || ' ' ||
    to_char(c1, '00') || '-' ||
    m_report_year || ' ' ||
    to_char(c11.UsageSec,'999,999,999,999') || ' ' ||
    to_char(c11.AvgSec,'999,999,999.999')
    end loop c11_loop;
    end loop c1_loop;
    for c1 in 7..9
    loop <<c1_loop>>
    for c11 in SessionUsagePOP4(
    m_report_year || lpad(c1, 2, '0') || '01000000',
    m_report_year || lpad(c1 + 1, 2, '0') || '01000000'
    loop <<c11_loop>>
    dbms_output.put_line(
    rpad(c11.PopName,25, ' ') || ' ' ||
    to_char(c1, '00') || '-' ||
    m_report_year || ' ' ||
    to_char(c11.UsageSec,'999,999,999,999') || ' ' ||
    to_char(c11.AvgSec,'999,999,999.999')
    end loop c11_loop;
    end loop c1_loop;
    for c1 in 7..9
    loop <<c1_loop>>
    for c11 in SessionUsagePOP5(
    m_report_year || lpad(c1, 2, '0') || '01000000',
    m_report_year || lpad(c1 + 1, 2, '0') || '01000000'
    loop <<c11_loop>>
    dbms_output.put_line(
    rpad(c11.PopName,25, ' ') || ' ' ||
    to_char(c1, '00') || '-' ||
    m_report_year || ' ' ||
    to_char(c11.UsageSec,'999,999,999,999') || ' ' ||
    to_char(c11.AvgSec,'999,999,999.999')
    end loop c11_loop;
    end loop c1_loop;
    for c1 in 7..9
    loop <<c1_loop>>
    for c11 in SessionUsagePOP6(
    m_report_year || lpad(c1, 2, '0') || '01000000',
    m_report_year || lpad(c1 + 1, 2, '0') || '01000000'
    loop <<c11_loop>>
    dbms_output.put_line(
    rpad(c11.PopName,25, ' ') || ' ' ||
    to_char(c1, '00') || '-' ||
    m_report_year || ' ' ||
    to_char(c11.UsageSec,'999,999,999,999') || ' ' ||
    to_char(c11.AvgSec,'999,999,999.999')
    end loop c11_loop;
    end loop c1_loop;
    for c1 in 7..9
    loop <<c1_loop>>
    for c11 in SessionUsagePOP7(
    m_report_year || lpad(c1, 2, '0') || '01000000',
    m_report_year || lpad(c1 + 1, 2, '0') || '01000000'
    loop <<c11_loop>>
    dbms_output.put_line(
    rpad(c11.PopName,25, ' ') || ' ' ||
    to_char(c1, '00') || '-' ||
    m_report_year || ' ' ||
    to_char(c11.UsageSec,'999,999,999,999') || ' ' ||
    to_char(c11.AvgSec,'999,999,999.999')
    end loop c11_loop;
    end loop c1_loop;
    for c1 in 7..9
    loop <<c1_loop>>
    for c11 in SessionUsagePOP8(
    m_report_year || lpad(c1, 2, '0') || '01000000',
    m_report_year || lpad(c1 + 1, 2, '0') || '01000000'
    loop <<c11_loop>>
    dbms_output.put_line(
    rpad(c11.PopName,25, ' ') || ' ' ||
    to_char(c1, '00') || '-' ||
    m_report_year || ' ' ||
    to_char(c11.UsageSec,'999,999,999,999') || ' ' ||
    to_char(c11.AvgSec,'999,999,999.999')
    end loop c11_loop;
    end loop c1_loop;
    for c1 in 7..9
    loop <<c1_loop>>
    for c11 in SessionUsagePOP9(
    m_report_year || lpad(c1, 2, '0') || '01000000',
    m_report_year || lpad(c1 + 1, 2, '0') || '01000000'
    loop <<c11_loop>>
    dbms_output.put_line(
    rpad(c11.PopName,25, ' ') || ' ' ||
    to_char(c1, '00') || '-' ||
    m_report_year || ' ' ||
    to_char(c11.UsageSec,'999,999,999,999') || ' ' ||
    to_char(c11.AvgSec,'999,999,999.999')
    end loop c11_loop;
    end loop c1_loop;
    for c1 in 7..9
    loop <<c1_loop>>
    for c11 in SessionUsagePOP10(
    m_report_year || lpad(c1, 2, '0') || '01000000',
    m_report_year || lpad(c1 + 1, 2, '0') || '01000000'
    loop <<c11_loop>>
    dbms_output.put_line(
    rpad(c11.PopName,25, ' ') || ' ' ||
    to_char(c1, '00') || '-' ||
    m_report_year || ' ' ||
    to_char(c11.UsageSec,'999,999,999,999') || ' ' ||
    to_char(c11.AvgSec,'999,999,999.999')
    end loop c11_loop;
    end loop c1_loop;
    end;
    spool off

Maybe you are looking for