Please help me to tune this PL/SQL...

Hi everyone,
    I have a SQL query which runs ok when i run it individually but the same query if
i use it in a procedure.The procedure is hanging up.Could someone please help to tune this
SQL query and please check my procedure why is it hanging up.
SQL Query
=========
SELECT active_members.member_nbr,
  active_members.name_last,
  active_members.name_first,
  active_members.name_middle,
  active_members.dob,
  active_members.sex,
  active_members.subsciber_nbr,
  active_members.ssn,
  active_members.name_suffix,
  active_members.class_x,
  active_members.aff_nbr,
CASE
WHEN TRIM(active_members.class_x) = 'SE' THEN
    (SELECT DISTINCT(mssp.member_nbr)
     FROM member_span mssp
     WHERE SUBSTR(mssp.member_nbr,    1,    9) = SUBSTR(active_members.member_nbr,    1,    9)
     AND mssp.class_x = 'SP'
     AND rownum = 1)
   WHEN TRIM(active_members.class_x) = 'SP' THEN
      (SELECT DISTINCT(mssp.member_nbr)
       FROM member_span mssp
       WHERE SUBSTR(mssp.member_nbr,    1,    9) = SUBSTR(active_members.member_nbr,    1,    9)
       AND mssp.class_x = 'SE'
       AND rownum = 1)
  ELSE
    NULL
   END)
spouse_member_nbr,
  active_members.division_nbr,
  active_members.ymdeff,
  active_members.ymdend,
  active_members.actual_ymd_enddt,
  active_members.email_id,
  active_members.network_id,
  active_members.insurance_company_code,
  active_members.cob_flag,
  active_members.vip_flag,
  active_members.pre_x_flag,
  active_members.region,
  active_contracts.language_x,
  active_contracts.corp_nbr,
  active_members.group_nbr,
  active_members.non_erisa_status
FROM
  (SELECT mb_active.member_nbr,
     mb_active.contract_nbr,
     mb_active.name_last,
     mb_active.name_first,
     mb_active.name_middle,
     ms_active.ymdeff,
     ms_active.ymdend,
     to_char(to_date(
   CASE
   WHEN LENGTH(mb_active.ymdbirth) = 8 THEN mb_active.ymdbirth
   ELSE NULL
   END,    'YYYYMMDD'),    'MM/DD/YYYY') dob,
     mb_active.sex,
     to_char(to_date(ms_active.ymdeff,    'YYYYMMDD'),    'MM/DD/YYYY') ymdeff_formatted,
     to_char(to_date(ms_active.ymdend,    'YYYYMMDD'),    'MM/DD/YYYY') ymdend_formatted,
     ms_active.void,
   CASE
   WHEN SUBSTR(mb_active.member_nbr,    10,    2) = '00' THEN mb_active.member_nbr
   ELSE SUBSTR(mb_active.member_nbr,    1,    9) || '00'
   END) subsciber_nbr,
     mb_active.ssn,
     mb_active.name_suffix,
     ms_active.class_x,
     ms_active.aff_nbr,
     ms_active.division_nbr,
   CASE
   WHEN TRIM(ms_active.ymdend) = '99991231' THEN NULL
   ELSE to_char(to_date(ms_active.ymdend,    'YYYYMMDD'),    'MM/DD/YYYY')
   END) actual_ymd_enddt,
   CASE
   WHEN TRIM(ms_active.business_unit) = '01' THEN ms_active.business_unit || '-' || ms_active.prog_nbr
   WHEN TRIM(ms_active.business_unit) = '03' THEN ms_active.business_unit || '-' || ms_active.prog_nbr || '-' || ms_active.carrier
   ELSE NULL
   END) network_id,
     ms_active.business_unit || '-' || ms_active.prog_nbr || '-' || ms_active.carrier insurance_company_code,
      (SELECT DISTINCT(email)
     FROM dbo.av_mem_email
     WHERE dbo.av_mem_email.member_nbr = mb_active.member_nbr
     AND rownum = 1)
  email_id,
     mb_active.lr_response cob_flag,
     mb_active.record_nbr vip_flag,
     ms_active.pre_exist pre_x_flag,
     ms_active.region region,
     ms_active.group_nbr,
   CASE
   WHEN
    (SELECT TRIM(div.div_status)
     FROM division div
     WHERE TRIM(div.division_nbr) = TRIM(ms_active.division_nbr)) = 'NULL' THEN
      'Y'
     ELSE
      'N'
     END)
  non_erisa_status
   FROM member mb_active,
     member_span ms_active
   WHERE mb_active.member_nbr = ms_active.member_nbr
   AND(20090707 BETWEEN ms_active.ymdeff
   AND ms_active.ymdend
   AND TRIM(ms_active.void) IS NULL
active_members,
    (SELECT DISTINCT(contract.contract_nbr),
     contract.language_x,
     contract_span.corp_nbr
   FROM contract,
     contract_span
   WHERE contract.contract_nbr = contract_span.contract_nbr
   AND(20090707 BETWEEN contract_span.ymdeff
   AND contract_span.ymdend)
   AND TRIM(contract_span.void) IS
  NULL)
active_contracts
WHERE TRIM(active_members.contract_nbr) = TRIM(active_contracts.contract_nbr);
Taking around 6 minute to run and it returns """"268267"""" records
Explain Plan for the above SQL:
===============================
"PLAN_TABLE_OUTPUT"
"Plan hash value: 379550299"
"| Id  | Operation                      | Name          | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |"
"|   0 | SELECT STATEMENT               |               |  2609K|   659M|       | 91679   (3)| 00:18:21 |"
"|   1 |  HASH UNIQUE                   |               |     1 |    16 |       | 54461   (2)| 00:10:54 |"
"|*  2 |   COUNT STOPKEY                |               |       |       |       |            |          |"
"|*  3 |    TABLE ACCESS FULL           | MEMBER_SPAN   | 12891 |   201K|       | 54459   (2)| 00:10:54 |"
"|   4 |    HASH UNIQUE                 |               |     1 |    16 |  2424K| 54736   (2)| 00:10:57 |"
"|*  5 |     COUNT STOPKEY              |               |       |       |       |            |          |"
"|*  6 |      TABLE ACCESS FULL         | MEMBER_SPAN   | 51541 |   805K|       | 54459   (2)| 00:10:54 |"
"|   7 |  HASH UNIQUE                   |               |     1 |    50 |       |    64   (4)| 00:00:01 |"
"|*  8 |   COUNT STOPKEY                |               |       |       |       |            |          |"
"|*  9 |    TABLE ACCESS FULL           | AV_MEM_EMAIL  |     1 |    50 |       |    63   (2)| 00:00:01 |"
"|* 10 |  TABLE ACCESS FULL             | DIVISION      |     1 |    14 |       |     3   (0)| 00:00:01 |"
"|* 11 |  HASH JOIN                     |               |  2609K|   659M|       | 91679   (3)| 00:18:21 |"
"|  12 |   VIEW                         |               |   581 | 12782 |       |  8184   (4)| 00:01:39 |"
"|  13 |    HASH UNIQUE                 |               |   581 | 26145 |       |  8184   (4)| 00:01:39 |"
"|  14 |     TABLE ACCESS BY INDEX ROWID| CONTRACT      |     1 |    14 |       |     2   (0)| 00:00:01 |"
"|  15 |      NESTED LOOPS              |               |   581 | 26145 |       |  8183   (4)| 00:01:39 |"
"|* 16 |       TABLE ACCESS FULL        | CONTRACT_SPAN |   581 | 18011 |       |  7019   (5)| 00:01:25 |"
"|* 17 |       INDEX RANGE SCAN         | CONTRACT_IX1  |     1 |       |       |     1   (0)| 00:00:01 |"
"|* 18 |   HASH JOIN                    |               |   449K|   104M|    39M| 83466   (2)| 00:16:42 |"
"|* 19 |    TABLE ACCESS FULL           | MEMBER_SPAN   |   449K|    34M|       | 54964   (3)| 00:11:00 |"
"|  20 |    TABLE ACCESS FULL           | MEMBER        |  1436K|   221M|       | 14664   (2)| 00:02:56 |"
"Predicate Information (identified by operation id):"
"   2 - filter(ROWNUM=1)"
"   3 - filter(SUBSTR("MSSP"."MEMBER_NBR",1,9)=SUBSTR(:B1,1,9) AND "MSSP"."CLASS_X"='SP')"
"   5 - filter(ROWNUM=1)"
"   6 - filter(SUBSTR("MSSP"."MEMBER_NBR",1,9)=SUBSTR(:B1,1,9) AND "MSSP"."CLASS_X"='SE')"
"   8 - filter(ROWNUM=1)"
"   9 - filter("AV_MEM_EMAIL"."MEMBER_NBR"=:B1)"
"  10 - filter(TRIM("DIV"."DIVISION_NBR")=TRIM(:B1))"
"  11 - access(TRIM("MB_ACTIVE"."CONTRACT_NBR")=TRIM("ACTIVE_CONTRACTS"."CONTRACT_NBR"))"
"  16 - filter("CONTRACT_SPAN"."YMDEFF"<=20090707 AND TRIM("CONTRACT_SPAN"."VOID") IS NULL AND "
"              "CONTRACT_SPAN"."YMDEND">=20090707)"
"  17 - access("CONTRACT"."CONTRACT_NBR"="CONTRACT_SPAN"."CONTRACT_NBR")"
"  18 - access("MB_ACTIVE"."MEMBER_NBR"="MS_ACTIVE"."MEMBER_NBR")"
"  19 - filter(TRIM("MS_ACTIVE"."VOID") IS NULL AND "MS_ACTIVE"."YMDEFF"<=20090707 AND "
"              "MS_ACTIVE"."YMDEND">=20090707)"
SAME SQL IN A PROCEDURE..IT IS HANGING UP
========================================
create or replace PROCEDURE TEST_CURRENT_PCP_SPAN is
EXTRACTED_STRING VARCHAR2(32767);
FILEHANDLER UTL_FILE.FILE_TYPE;
test_str varchar2(100);
pcp_eff_date number(10);
file_name varchar2(50);
   CURSOR MEMBERS
   IS
SELECT active_members.member_nbr,
  active_members.name_last,
  active_members.name_first,
  active_members.name_middle,
  active_members.dob,
  active_members.sex,
  active_members.subsciber_nbr,
  active_members.ssn,
  active_members.name_suffix,
  active_members.class_x,
  active_members.aff_nbr,
CASE
WHEN TRIM(active_members.class_x) = 'SE' THEN
    (SELECT DISTINCT(mssp.member_nbr)
     FROM member_span mssp
     WHERE SUBSTR(mssp.member_nbr,    1,    9) = SUBSTR(active_members.member_nbr,    1,    9)
     AND mssp.class_x = 'SP'
     AND rownum = 1)
   WHEN TRIM(active_members.class_x) = 'SP' THEN
      (SELECT DISTINCT(mssp.member_nbr)
       FROM member_span mssp
       WHERE SUBSTR(mssp.member_nbr,    1,    9) = SUBSTR(active_members.member_nbr,    1,    9)
       AND mssp.class_x = 'SE'
       AND rownum = 1)
  ELSE
    NULL
   END)
spouse_member_nbr,
  active_members.division_nbr,
  active_members.ymdeff,
  active_members.ymdend,
  active_members.actual_ymd_enddt,
  active_members.email_id,
  active_members.network_id,
  active_members.insurance_company_code,
  active_members.cob_flag,
  active_members.vip_flag,
  active_members.pre_x_flag,
  active_members.region,
  active_contracts.language_x,
  active_contracts.corp_nbr,
  active_members.group_nbr,
  active_members.non_erisa_status
FROM
  (SELECT mb_active.member_nbr,
     mb_active.contract_nbr,
     mb_active.name_last,
     mb_active.name_first,
     mb_active.name_middle,
     ms_active.ymdeff,
     ms_active.ymdend,
     to_char(to_date(
   CASE
   WHEN LENGTH(mb_active.ymdbirth) = 8 THEN mb_active.ymdbirth
   ELSE NULL
   END,    'YYYYMMDD'),    'MM/DD/YYYY') dob,
     mb_active.sex,
     to_char(to_date(ms_active.ymdeff,    'YYYYMMDD'),    'MM/DD/YYYY') ymdeff_formatted,
     to_char(to_date(ms_active.ymdend,    'YYYYMMDD'),    'MM/DD/YYYY') ymdend_formatted,
     ms_active.void,
   CASE
   WHEN SUBSTR(mb_active.member_nbr,    10,    2) = '00' THEN mb_active.member_nbr
   ELSE SUBSTR(mb_active.member_nbr,    1,    9) || '00'
   END) subsciber_nbr,
     mb_active.ssn,
     mb_active.name_suffix,
     ms_active.class_x,
     ms_active.aff_nbr,
     ms_active.division_nbr,
   CASE
   WHEN TRIM(ms_active.ymdend) = '99991231' THEN NULL
   ELSE to_char(to_date(ms_active.ymdend,    'YYYYMMDD'),    'MM/DD/YYYY')
   END) actual_ymd_enddt,
   CASE
   WHEN TRIM(ms_active.business_unit) = '01' THEN ms_active.business_unit || '-' || ms_active.prog_nbr
   WHEN TRIM(ms_active.business_unit) = '03' THEN ms_active.business_unit || '-' || ms_active.prog_nbr || '-' || ms_active.carrier
   ELSE NULL
   END) network_id,
     ms_active.business_unit || '-' || ms_active.prog_nbr || '-' || ms_active.carrier insurance_company_code,
      (SELECT DISTINCT(email)
     FROM dbo.av_mem_email
     WHERE dbo.av_mem_email.member_nbr = mb_active.member_nbr
     AND rownum = 1)
  email_id,
     mb_active.lr_response cob_flag,
     mb_active.record_nbr vip_flag,
     ms_active.pre_exist pre_x_flag,
     ms_active.region region,
     ms_active.group_nbr,
   CASE
   WHEN
    (SELECT TRIM(div.div_status)
     FROM division div
     WHERE TRIM(div.division_nbr) = TRIM(ms_active.division_nbr)) = 'NULL' THEN
      'Y'
     ELSE
      'N'
     END)
  non_erisa_status
   FROM member mb_active,
     member_span ms_active
   WHERE mb_active.member_nbr = ms_active.member_nbr
   AND(20090707 BETWEEN ms_active.ymdeff
   AND ms_active.ymdend
   AND TRIM(ms_active.void) IS NULL
active_members,
    (SELECT DISTINCT(contract.contract_nbr),
     contract.language_x,
     contract_span.corp_nbr
   FROM contract,
     contract_span
   WHERE contract.contract_nbr = contract_span.contract_nbr
   AND(20090707 BETWEEN contract_span.ymdeff
   AND contract_span.ymdend)
   AND TRIM(contract_span.void) IS
  NULL)
active_contracts
WHERE TRIM(active_members.contract_nbr) = TRIM(active_contracts.contract_nbr);
  TYPE MEM IS TABLE OF MEMBERS%ROWTYPE INDEX BY PLS_INTEGER;
  TABLE_MEM MEM;
MEMBER_ADDR   MGONZALEZ.CPKG_UTIL.ADDR;
BEGIN 
   test_str := '''A10000213'''||','||'''A10000213''';
   insert into test_number_char(str) values ('start time of MEMBER_LOAD_CURRENT_PCP_SPAN '||to_char(sysdate,'MM/DD/YYYY HH24:MI:SS'));
   commit;
   file_name := 'member_load'||to_char(sysdate,'YYYYMMDDHH24MI')||'.txt';
   FILEHANDLER := UTL_FILE.FOPEN('AVMED_UTL_FILE',file_name, 'W',10000);
   insert into test_number_char(str) values ('start time of opening members cursor(before open members command) '||to_char(sysdate,'MM/DD/YYYY HH24:MI:SS'));
   commit;
   OPEN MEMBERS;
LOOP
      FETCH MEMBERS
         BULK COLLECT INTO TABLE_MEM LIMIT 1000 ;
       EXIT WHEN TABLE_MEM.COUNT = 0;
insert into test_number_char(str) values ('start time of outer loop '||to_char(sysdate,'MM/DD/YYYY HH24:MI:SS'));
commit;
      FOR i IN 1 .. TABLE_MEM.COUNT
      LOOP
      EXTRACTED_STRING := TRIM(TABLE_MEM(i).MEMBER_NBR)||'| '||     
                          TRIM(TABLE_MEM(i).NAME_LAST)||'| '||      
                        TRIM(TABLE_MEM(i).NAME_FIRST)||'| '||      
                         TRIM(TABLE_MEM(i).NAME_MIDDLE)||'| '||   
                         TRIM(TABLE_MEM(i).ssn)||'| '||            
                         TABLE_MEM(i).subsciber_nbr||'| '||        
                         TRIM(TABLE_MEM(i).class_x)||'| '||         
                         TRIM(TABLE_MEM(i).DOB)||'| '||             
                         TRIM(TABLE_MEM(i).SEX)||'| ' ;             
          EXTRACTED_STRING   :=
                EXTRACTED_STRING ||
              TRIM(TABLE_MEM(i).aff_nbr)||'| '||                         
                            pcp_eff_date||'| '||                 
          TABLE_MEM(i).actual_ymd_enddt||'| '||                        
              TRIM(TABLE_MEM(i).division_nbr)||'| '||                    
              ' '||'| '||                                               
              ' '||'| '||                                                  
              ' '||'| '||                                                 
              TABLE_MEM(i).network_id||'| '||                              
              ' '||'| '||                                                  
              ' '||'| '||                                                  
              ' '||'| '||                                                  
              ' '||'| '||                                                 
              ' '||'| '||                                                  
             TRIM(TABLE_MEM(i).name_suffix)||'| '||                       
             ' '||'| '||                                                   
             TRIM(TABLE_MEM(i).spouse_member_nbr)||'| '||                  
             ' '||'| '||                                                   
             ' '||'| '||                                                   
             ' '||'| '||                                                  
             ' '||'| '||                                                   
             ' '||'| '||                                                  
             ' '||'| '||                                                   
             ' '||'| '||                                                   
             ' '||'| '||                                                   
             ' '||'| '||                                                   
             ' '||'| '||                                                   
             ' '||'| '||                                                   
             ' '||'| '||                                                  
             ' '||'| '||                                                   
            TRIM(TABLE_MEM(i).email_id)||'| '||                                
            TABLE_MEM(i).Insurance_company_code||'| '||                    
            TABLE_MEM(i).group_nbr||'| '||                                 
            TABLE_MEM(i).language_x||'| '||                               
            TABLE_MEM(i).region||'| '||                                    
            TABLE_MEM(i).corp_nbr||'| '||                                  
            TABLE_MEM(i).non_erisa_status||'| '||                          
            TABLE_MEM(i).cob_flag||'| '||                                  
            TABLE_MEM(i).pre_x_flag||'| '||                                
            TABLE_MEM(i).vip_flag                                       
             EXTRACTED_STRING   := rtrim(EXTRACTED_STRING,' ');
        UTL_FILE.PUT_LINE(FILEHANDLER,EXTRACTED_STRING,TRUE);
        EXTRACTED_STRING := NULL;
        pcp_eff_date := NULL;
      END LOOP;
      insert into test_number_char(str) values ('end time of outer loop '||to_char(sysdate,'MM/DD/YYYY HH24:MI:SS'));
commit;
END LOOP;
close members;
insert into test_number_char(str) values ('end time of opening members cursor '||to_char(sysdate,'MM/DD/YYYY HH24:MI:SS'));
commit;
commit;
   UTL_FILE.FCLOSE(FILEHANDLER);
   insert into test_number_char(str) values ('End time of MEMBER_LOAD_CURRENT_PCP_SPAN '||to_char(sysdate,'MM/DD/YYYY HH24:MI:SS'));
   commit;
   EXCEPTION
      WHEN OTHERS
      THEN
         DBMS_OUTPUT.put_line(   'ERROR getting members '
                              || SQLCODE
                              || ' '
                              || SQLERRM);
END ;
In my Test table which i am inserting to check the times...
I am geting on these 2 records after that it hangs up...
start time of MEMBER_LOAD_CURRENT_PCP_SPAN 07/08/2009 11:41:21
start time of opening members cursor(before open members command) 07/08/2009 11:41:21I have to call some other functions for each member to get additional details thats the reason i am going for Procedure.Instead it is just a simple SQL
Thanks in advance

It is taking lot of timeYou could perhaps split it up in smaller, isolated parts.
Running certain steps separate.
..is it possible to find out the issues without running the proc?Other than have other people on OTN give their ideas/share experiences?
Not that I'm aware of.
There are lots of statistical views, you might be able to deduct from their data, but I personally prefer running the procedure and just trace it. But I'm always willing to learn new approaches, btw.
Still, you have 2 things to look at, at least:
- avoid loops in loops if possible
- check your predicates, if you apply a function, you lose the index, unless you create a function based index.
edit
One more thing (how could I overlook that):
You commit your instrumentation code ( insert into test_number_char(str) ) IN the loop.
Please remove commit in your loops...
Commit only once, at the end of your transaction.
Never commit in a loop.
(Preferrably the client commits)
And remove every commit in your loop...
Edited by: hoek on Jul 8, 2009 8:03 PM

Similar Messages

  • Sql Query Tuning. Please help me to tune this query

    Hi All ,
    I have this problematic Sql . It is taking huge time to execute. It contains a view CIDV, which i think is the bottleneck.
    I have pasted the query below. I will be pasting TKPROF and explain plan for the same. Please advice me to tune this query.
    SELECT GCC.SEGMENT1 || '.' || GCC.SEGMENT2 || '.' || GCC.SEGMENT3 || '.' ||
           GCC.SEGMENT4 || '.' || GCC.SEGMENT5 || '.' || GCC.SEGMENT6 || '.' ||
           GCC.SEGMENT7 || '.' || GCC.SEGMENT8 || '.' || GCC.SEGMENT9 OFFSET_ACCOUNT,
           OOD.ORGANIZATION_CODE,
           CIDV.SUBINVENTORY_CODE OFFSET_SUBINV,
           MIL.SEGMENT1 || '.' || MIL.SEGMENT2 || '.' || MIL.SEGMENT3 || '.' ||
           MIL.SEGMENT4 || '.' || MIL.SEGMENT5 OFFSET_LOCATOR,
           CIDV.LAST_UPDATE_LOGIN
      FROM APPS.CST_INV_DISTRIBUTION_V       CIDV,
           APPS.GL_CODE_COMBINATIONS         GCC,
           APPS.MTL_ITEM_LOCATIONS           MIL,
           APPS.ORG_ORGANIZATION_DEFINITIONS OOD
    WHERE CIDV.TRANSACTION_ID = :B2
       AND CIDV.PRIMARY_QUANTITY = (-1) * :B1
       AND CIDV.REFERENCE_ACCOUNT = GCC.CODE_COMBINATION_ID
       AND OOD.ORGANIZATION_ID = CIDV.ORGANIZATION_ID
       AND MIL.INVENTORY_LOCATION_ID = CIDV.LOCATOR_ID
       AND GCC.ACCOUNT_TYPE = 'A'****************
    TKPROF
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute  68337     10.32      10.32          0          0          0           0
    Fetch    68337    229.75     936.36      58819    6743323       1121       68232
    total   136675    240.07     946.69      58819    6743323       1121       68232
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 203     (recursive depth: 1)
    Number of plan statistics captured: 1
    Rows (1st) Rows (avg) Rows (max)  Row Source Operation
             1          1          1  MERGE JOIN CARTESIAN (cr=102 pr=15 pw=0 time=193608 us cost=56 size=219 card=1)
             1          1          1   NESTED LOOPS  (cr=100 pr=15 pw=0 time=193483 us cost=53 size=219 card=1)
             1          1          1    NESTED LOOPS  (cr=99 pr=15 pw=0 time=193407 us cost=52 size=215 card=1)
             1          1          1     NESTED LOOPS  (cr=96 pr=15 pw=0 time=193378 us cost=51 size=190 card=1)
             1          1          1      NESTED LOOPS  (cr=93 pr=15 pw=0 time=193284 us cost=49 size=162 card=1)
             1          1          1       NESTED LOOPS  (cr=89 pr=14 pw=0 time=185515 us cost=46 size=138 card=1)
             1          1          1        NESTED LOOPS  (cr=85 pr=12 pw=0 time=157975 us cost=44 size=81 card=1)
             1          1          1         NESTED LOOPS  (cr=83 pr=12 pw=0 time=157925 us cost=43 size=73 card=1)
             1          1          1          NESTED LOOPS  (cr=81 pr=12 pw=0 time=157641 us cost=43 size=132 card=2)
             1          1          1           VIEW  CST_INV_DISTRIBUTION_V (cr=78 pr=12 pw=0 time=156386 us cost=41 size=118 card=2)
             1          1          1            UNION-ALL  (cr=78 pr=12 pw=0 time=156378 us)
             0          0          0             NESTED LOOPS OUTER (cr=44 pr=9 pw=0 time=124997 us cost=20 size=291 card=1)
             0          0          0              NESTED LOOPS  (cr=44 pr=9 pw=0 time=124993 us cost=18 size=255 card=1)
             0          0          0               NESTED LOOPS  (cr=44 pr=9 pw=0 time=124990 us cost=18 size=251 card=1)
            33         33         33                MERGE JOIN CARTESIAN (cr=25 pr=6 pw=0 time=98544 us cost=14 size=192 card=1)
             1          1          1                 NESTED LOOPS OUTER (cr=22 pr=5 pw=0 time=85754 us cost=12 size=156 card=1)
             1          1          1                  NESTED LOOPS  (cr=19 pr=4 pw=0 time=79830 us cost=10 size=120 card=1)
             1          1          1                   NESTED LOOPS OUTER (cr=17 pr=4 pw=0 time=79813 us cost=9 size=113 card=1)
             1          1          1                    NESTED LOOPS  (cr=15 pr=4 pw=0 time=79752 us cost=8 size=106 card=1)
             1          1          1                     NESTED LOOPS  (cr=11 pr=2 pw=0 time=43120 us cost=6 size=93 card=1)
             1          1          1                      NESTED LOOPS  (cr=7 pr=2 pw=0 time=43087 us cost=4 size=83 card=1)
             1          1          1                       NESTED LOOPS  (cr=6 pr=2 pw=0 time=43072 us cost=4 size=80 card=1)
             1          1          1                        TABLE ACCESS BY INDEX ROWID MTL_MATERIAL_TRANSACTIONS (cr=5 pr=2 pw=0 time=43042 us cost=4 size=76 card=1)
             1          1          1                         INDEX UNIQUE SCAN MTL_MATERIAL_TRANSACTIONS_U1 (cr=4 pr=2 pw=0 time=43011 us cost=3 size=0 card=1)(object id 12484094)
             1          1          1                        INDEX UNIQUE SCAN MTL_TRANSACTION_TYPES_U1 (cr=1 pr=0 pw=0 time=20 us cost=0 size=764 card=191)(object id 9983)
             1          1          1                       INDEX UNIQUE SCAN MTL_TXN_SOURCE_TYPES_U1 (cr=1 pr=0 pw=0 time=7 us cost=0 size=54 card=18)(object id 9987)
             1          1          1                      INDEX UNIQUE SCAN MTL_SYSTEM_ITEMS_B_U1 (cr=4 pr=0 pw=0 time=27 us cost=2 size=736324450 card=73632445)(object id 12484155)
             1          1          1                     INDEX UNIQUE SCAN MTL_SYSTEM_ITEMS_TL_U1 (cr=4 pr=2 pw=0 time=36626 us cost=2 size=957481070 card=73652390)(object id 12484137)
             1          1          1                    TABLE ACCESS BY INDEX ROWID MTL_PARAMETERS (cr=2 pr=0 pw=0 time=42 us cost=1 size=3290 card=470)
             1          1          1                     INDEX UNIQUE SCAN MTL_PARAMETERS_U1 (cr=1 pr=0 pw=0 time=28 us cost=0 size=0 card=1)(object id 9847)
             1          1          1                   TABLE ACCESS BY INDEX ROWID MTL_PARAMETERS (cr=2 pr=0 pw=0 time=12 us cost=1 size=3290 card=470)
             1          1          1                    INDEX UNIQUE SCAN MTL_PARAMETERS_U1 (cr=1 pr=0 pw=0 time=7 us cost=0 size=0 card=1)(object id 9847)
             0          0          0                  INDEX RANGE SCAN FND_LOOKUP_VALUES_U1 (cr=3 pr=1 pw=0 time=5915 us cost=2 size=36 card=1)(object id 705891)
            33         33         33                 BUFFER SORT (cr=3 pr=1 pw=0 time=12713 us cost=12 size=36 card=1)
            33         33         33                  INDEX RANGE SCAN FND_LOOKUP_VALUES_U1 (cr=3 pr=1 pw=0 time=12582 us cost=2 size=36 card=1)(object id 705891)
             0          0          0                TABLE ACCESS BY INDEX ROWID MTL_TRANSACTION_ACCOUNTS (cr=19 pr=3 pw=0 time=26591 us cost=4 size=59 card=1)
            66         66         66                 INDEX RANGE SCAN MTL_TRANSACTION_ACCOUNTS_N1 (cr=18 pr=2 pw=0 time=13607 us cost=3 size=0 card=3)(object id 12484127)
             0          0          0               INDEX UNIQUE SCAN MTL_PARAMETERS_U1 (cr=0 pr=0 pw=0 time=0 us cost=0 size=4 card=1)(object id 9847)
             0          0          0              INDEX RANGE SCAN FND_LOOKUP_VALUES_U1 (cr=0 pr=0 pw=0 time=0 us cost=2 size=36 card=1)(object id 705891)
             1          1          1             NESTED LOOPS  (cr=34 pr=3 pw=0 time=31269 us cost=21 size=288 card=1)
             1          1          1              NESTED LOOPS  (cr=30 pr=3 pw=0 time=31161 us cost=19 size=275 card=1)
             1          1          1               NESTED LOOPS  (cr=26 pr=3 pw=0 time=31105 us cost=17 size=265 card=1)
             1          1          1                NESTED LOOPS  (cr=25 pr=3 pw=0 time=31082 us cost=17 size=261 card=1)
             1          1          1                 NESTED LOOPS OUTER (cr=23 pr=3 pw=0 time=31027 us cost=16 size=254 card=1)
             1          1          1                  NESTED LOOPS  (cr=21 pr=3 pw=0 time=30980 us cost=15 size=247 card=1)
             1          1          1                   NESTED LOOPS  (cr=20 pr=3 pw=0 time=30957 us cost=15 size=243 card=1)
             1          1          1                    NESTED LOOPS OUTER (cr=19 pr=3 pw=0 time=30926 us cost=15 size=240 card=1)
             1          1          1                     NESTED LOOPS  (cr=16 pr=3 pw=0 time=30389 us cost=13 size=204 card=1)
             1          1          1                      NESTED LOOPS  (cr=11 pr=0 pw=0 time=665 us cost=9 size=131 card=1)
             1          1          1                       NESTED LOOPS OUTER (cr=8 pr=0 pw=0 time=306 us cost=7 size=95 card=1)
             1          1          1                        TABLE ACCESS BY INDEX ROWID MTL_TRANSACTION_ACCOUNTS (cr=5 pr=0 pw=0 time=37 us cost=5 size=59 card=1)
             2          2          2                         INDEX RANGE SCAN MTL_TRANSACTION_ACCOUNTS_N1 (cr=4 pr=0 pw=0 time=17 us cost=4 size=0 card=3)(object id 12484127)
             1          1          1                        INDEX RANGE SCAN FND_LOOKUP_VALUES_U1 (cr=3 pr=0 pw=0 time=216 us cost=2 size=36 card=1)(object id 705891)
             1          1          1                       INDEX RANGE SCAN FND_LOOKUP_VALUES_U1 (cr=3 pr=0 pw=0 time=352 us cost=2 size=36 card=1)(object id 705891)
             1          1          1                      TABLE ACCESS BY INDEX ROWID MTL_MATERIAL_TRANSACTIONS (cr=5 pr=3 pw=0 time=29716 us cost=4 size=73 card=1)
             1          1          1                       INDEX RANGE SCAN MTL_MATERIAL_TRANSACTIONS_N23 (cr=4 pr=3 pw=0 time=29588 us cost=3 size=0 card=1)(object id 12484133)
             0          0          0                     INDEX RANGE SCAN FND_LOOKUP_VALUES_U1 (cr=3 pr=0 pw=0 time=520 us cost=2 size=36 card=1)(object id 705891)
             1          1          1                    INDEX UNIQUE SCAN MTL_TXN_SOURCE_TYPES_U1 (cr=1 pr=0 pw=0 time=22 us cost=0 size=3 card=1)(object id 9987)
             1          1          1                   INDEX UNIQUE SCAN MTL_TRANSACTION_TYPES_U1 (cr=1 pr=0 pw=0 time=16 us cost=0 size=4 card=1)(object id 9983)
             1          1          1                  TABLE ACCESS BY INDEX ROWID MTL_PARAMETERS (cr=2 pr=0 pw=0 time=34 us cost=1 size=7 card=1)
             1          1          1                   INDEX UNIQUE SCAN MTL_PARAMETERS_U1 (cr=1 pr=0 pw=0 time=19 us cost=0 size=0 card=1)(object id 9847)
             1          1          1                 TABLE ACCESS BY INDEX ROWID MTL_PARAMETERS (cr=2 pr=0 pw=0 time=44 us cost=1 size=7 card=1)
             1          1          1                  INDEX UNIQUE SCAN MTL_PARAMETERS_U1 (cr=1 pr=0 pw=0 time=14 us cost=0 size=0 card=1)(object id 9847)
             1          1          1                INDEX UNIQUE SCAN MTL_PARAMETERS_U1 (cr=1 pr=0 pw=0 time=13 us cost=0 size=4 card=1)(object id 9847)
             1          1          1               INDEX UNIQUE SCAN MTL_SYSTEM_ITEMS_B_U1 (cr=4 pr=0 pw=0 time=49 us cost=2 size=10 card=1)(object id 12484155)
             1          1          1              INDEX UNIQUE SCAN MTL_SYSTEM_ITEMS_TL_U1 (cr=4 pr=0 pw=0 time=96 us cost=2 size=13 card=1)(object id 12484137)
             1          1          1           TABLE ACCESS BY INDEX ROWID HR_ALL_ORGANIZATION_UNITS (cr=3 pr=0 pw=0 time=1246 us cost=1 size=7 card=1)
             1          1          1            INDEX UNIQUE SCAN HR_ORGANIZATION_UNITS_PK (cr=2 pr=0 pw=0 time=24 us cost=0 size=0 card=1)(object id 250158)
             1          1          1          INDEX UNIQUE SCAN HR_ALL_ORGANIZATION_UNTS_TL_PK (cr=2 pr=0 pw=0 time=275 us cost=0 size=7 card=1)(object id 689101)
             1          1          1         TABLE ACCESS BY INDEX ROWID MTL_PARAMETERS (cr=2 pr=0 pw=0 time=38 us cost=1 size=8 card=1)
             1          1          1          INDEX UNIQUE SCAN MTL_PARAMETERS_U1 (cr=1 pr=0 pw=0 time=15 us cost=0 size=0 card=1)(object id 9847)
             1          1          1        TABLE ACCESS BY INDEX ROWID GL_CODE_COMBINATIONS (cr=4 pr=2 pw=0 time=27531 us cost=2 size=57 card=1)
             1          1          1         INDEX UNIQUE SCAN GL_CODE_COMBINATIONS_U1 (cr=3 pr=1 pw=0 time=19925 us cost=1 size=0 card=1)(object id 51426)
             1          1          1       TABLE ACCESS BY INDEX ROWID MTL_ITEM_LOCATIONS (cr=4 pr=1 pw=0 time=7758 us cost=3 size=24 card=1)
             1          1          1        INDEX RANGE SCAN MTL_ITEM_LOCATIONS_U1 (cr=3 pr=0 pw=0 time=51 us cost=2 size=0 card=1)(object id 9761)
             1          1          1      TABLE ACCESS BY INDEX ROWID HR_ORGANIZATION_INFORMATION (cr=3 pr=0 pw=0 time=85 us cost=2 size=28 card=1)
             1          1          1       INDEX RANGE SCAN HR_ORGANIZATION_INFORMATIO_FK2 (cr=2 pr=0 pw=0 time=29 us cost=1 size=0 card=2)(object id 5379798)
             1          1          1     TABLE ACCESS BY INDEX ROWID HR_ORGANIZATION_INFORMATION (cr=3 pr=0 pw=0 time=25 us cost=1 size=25 card=1)
             1          1          1      INDEX RANGE SCAN HR_ORGANIZATION_INFORMATIO_FK2 (cr=2 pr=0 pw=0 time=11 us cost=1 size=0 card=1)(object id 5379798)
             1          1          1    INDEX FULL SCAN GL_SETS_OF_BOOKS_U2 (cr=1 pr=0 pw=0 time=69 us cost=1 size=4 card=1)(object id 1380842)
             1          1          1   BUFFER SORT (cr=2 pr=0 pw=0 time=110 us cost=55 size=0 card=1)
             1          1          1    TABLE ACCESS FULL FND_PRODUCT_GROUPS (cr=2 pr=0 pw=0 time=59 us cost=3 size=0 card=1)
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      library cache lock                              2        0.00          0.00
      library cache pin                               2        0.00          0.00
      Disk file operations I/O                      249        0.00          0.00
      db file sequential read                     58819        2.61        714.28
      gc cr grant 2-way                            5198        0.16          4.52
      gc current grant busy                           1        0.00          0.00
      KJC: Wait for msg sends to complete           517        0.00          0.05
      library cache: mutex X                        433        0.01          0.04
      gc cr grant congested                          28        0.08          0.18
      latch: ges resource hash list                   5        0.00          0.00
      gc current block 2-way                        513        0.11          0.61
      gc current block congested                      2        0.00          0.00
      latch: gc element                              16        0.00          0.01
      latch: cache buffers chains                     4        0.00          0.00
      latch: object queue header operation            3        0.00          0.00
    ********************************************************************************

    Explain Plan for the query
    SELECT STATEMENT, GOAL = ALL_ROWS               Cost=56     Cardinality=1     Bytes=219
    MERGE JOIN CARTESIAN               Cost=56     Cardinality=1     Bytes=219
      NESTED LOOPS               Cost=53     Cardinality=1     Bytes=219
       NESTED LOOPS               Cost=52     Cardinality=1     Bytes=215
        NESTED LOOPS               Cost=51     Cardinality=1     Bytes=190
         NESTED LOOPS               Cost=49     Cardinality=1     Bytes=162
          NESTED LOOPS               Cost=46     Cardinality=1     Bytes=138
           NESTED LOOPS               Cost=44     Cardinality=1     Bytes=81
            NESTED LOOPS               Cost=43     Cardinality=1     Bytes=73
             NESTED LOOPS               Cost=43     Cardinality=2     Bytes=132
              VIEW     Object owner=APPS     Object name=CST_INV_DISTRIBUTION_V     Cost=41     Cardinality=2     Bytes=118
               UNION-ALL                         
                NESTED LOOPS OUTER               Cost=20     Cardinality=1     Bytes=291
                 NESTED LOOPS               Cost=18     Cardinality=1     Bytes=255
                  NESTED LOOPS               Cost=18     Cardinality=1     Bytes=251
                   MERGE JOIN CARTESIAN               Cost=14     Cardinality=1     Bytes=192
                    NESTED LOOPS OUTER               Cost=12     Cardinality=1     Bytes=156
                     NESTED LOOPS               Cost=10     Cardinality=1     Bytes=120
                      NESTED LOOPS OUTER               Cost=9     Cardinality=1     Bytes=113
                       NESTED LOOPS               Cost=8     Cardinality=1     Bytes=106
                        NESTED LOOPS               Cost=6     Cardinality=1     Bytes=93
                         NESTED LOOPS               Cost=4     Cardinality=1     Bytes=83
                          NESTED LOOPS               Cost=4     Cardinality=1     Bytes=80
                           TABLE ACCESS BY INDEX ROWID     Object owner=INV     Object name=MTL_MATERIAL_TRANSACTIONS     Cost=4     Cardinality=1     Bytes=76
                            INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_MATERIAL_TRANSACTIONS_U1     Cost=3     Cardinality=1     
                           INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_TRANSACTION_TYPES_U1     Cost=0     Cardinality=191     Bytes=764
                          INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_TXN_SOURCE_TYPES_U1     Cost=0     Cardinality=18     Bytes=54
                         INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_SYSTEM_ITEMS_B_U1     Cost=2     Cardinality=73632445     Bytes=736324450
                        INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_SYSTEM_ITEMS_TL_U1     Cost=2     Cardinality=73652390     Bytes=957481070
                       TABLE ACCESS BY INDEX ROWID     Object owner=INV     Object name=MTL_PARAMETERS     Cost=1     Cardinality=470     Bytes=3290
                        INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_PARAMETERS_U1     Cost=0     Cardinality=1     
                      TABLE ACCESS BY INDEX ROWID     Object owner=INV     Object name=MTL_PARAMETERS     Cost=1     Cardinality=470     Bytes=3290
                       INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_PARAMETERS_U1     Cost=0     Cardinality=1     
                     INDEX RANGE SCAN     Object owner=APPLSYS     Object name=FND_LOOKUP_VALUES_U1     Cost=2     Cardinality=1     Bytes=36
                    BUFFER SORT               Cost=12     Cardinality=1     Bytes=36
                     INDEX RANGE SCAN     Object owner=APPLSYS     Object name=FND_LOOKUP_VALUES_U1     Cost=2     Cardinality=1     Bytes=36
                   TABLE ACCESS BY INDEX ROWID     Object owner=INV     Object name=MTL_TRANSACTION_ACCOUNTS     Cost=4     Cardinality=1     Bytes=59
                    INDEX RANGE SCAN     Object owner=INV     Object name=MTL_TRANSACTION_ACCOUNTS_N1     Cost=3     Cardinality=3     
                  INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_PARAMETERS_U1     Cost=0     Cardinality=1     Bytes=4
                 INDEX RANGE SCAN     Object owner=APPLSYS     Object name=FND_LOOKUP_VALUES_U1     Cost=2     Cardinality=1     Bytes=36
                NESTED LOOPS               Cost=21     Cardinality=1     Bytes=288
                 NESTED LOOPS               Cost=19     Cardinality=1     Bytes=275
                  NESTED LOOPS               Cost=17     Cardinality=1     Bytes=265
                   NESTED LOOPS               Cost=17     Cardinality=1     Bytes=261
                    NESTED LOOPS OUTER               Cost=16     Cardinality=1     Bytes=254
                     NESTED LOOPS               Cost=15     Cardinality=1     Bytes=247
                      NESTED LOOPS               Cost=15     Cardinality=1     Bytes=243
                       NESTED LOOPS OUTER               Cost=15     Cardinality=1     Bytes=240
                        NESTED LOOPS               Cost=13     Cardinality=1     Bytes=204
                         NESTED LOOPS               Cost=9     Cardinality=1     Bytes=131
                          NESTED LOOPS OUTER               Cost=7     Cardinality=1     Bytes=95
                           TABLE ACCESS BY INDEX ROWID     Object owner=INV     Object name=MTL_TRANSACTION_ACCOUNTS     Cost=5     Cardinality=1     Bytes=59
                            INDEX RANGE SCAN     Object owner=INV     Object name=MTL_TRANSACTION_ACCOUNTS_N1     Cost=4     Cardinality=3     
                           INDEX RANGE SCAN     Object owner=APPLSYS     Object name=FND_LOOKUP_VALUES_U1     Cost=2     Cardinality=1     Bytes=36
                          INDEX RANGE SCAN     Object owner=APPLSYS     Object name=FND_LOOKUP_VALUES_U1     Cost=2     Cardinality=1     Bytes=36
                         TABLE ACCESS BY INDEX ROWID     Object owner=INV     Object name=MTL_MATERIAL_TRANSACTIONS     Cost=4     Cardinality=1     Bytes=73
                          INDEX RANGE SCAN     Object owner=INV     Object name=MTL_MATERIAL_TRANSACTIONS_N23     Cost=3     Cardinality=1     
                        INDEX RANGE SCAN     Object owner=APPLSYS     Object name=FND_LOOKUP_VALUES_U1     Cost=2     Cardinality=1     Bytes=36
                       INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_TXN_SOURCE_TYPES_U1     Cost=0     Cardinality=1     Bytes=3
                      INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_TRANSACTION_TYPES_U1     Cost=0     Cardinality=1     Bytes=4
                     TABLE ACCESS BY INDEX ROWID     Object owner=INV     Object name=MTL_PARAMETERS     Cost=1     Cardinality=1     Bytes=7
                      INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_PARAMETERS_U1     Cost=0     Cardinality=1     
                    TABLE ACCESS BY INDEX ROWID     Object owner=INV     Object name=MTL_PARAMETERS     Cost=1     Cardinality=1     Bytes=7
                     INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_PARAMETERS_U1     Cost=0     Cardinality=1     
                   INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_PARAMETERS_U1     Cost=0     Cardinality=1     Bytes=4
                  INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_SYSTEM_ITEMS_B_U1     Cost=2     Cardinality=1     Bytes=10
                 INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_SYSTEM_ITEMS_TL_U1     Cost=2     Cardinality=1     Bytes=13
              TABLE ACCESS BY INDEX ROWID     Object owner=HR     Object name=HR_ALL_ORGANIZATION_UNITS     Cost=1     Cardinality=1     Bytes=7
               INDEX UNIQUE SCAN     Object owner=HR     Object name=HR_ORGANIZATION_UNITS_PK     Cost=0     Cardinality=1     
             INDEX UNIQUE SCAN     Object owner=HR     Object name=HR_ALL_ORGANIZATION_UNTS_TL_PK     Cost=0     Cardinality=1     Bytes=7
            TABLE ACCESS BY INDEX ROWID     Object owner=INV     Object name=MTL_PARAMETERS     Cost=1     Cardinality=1     Bytes=8
             INDEX UNIQUE SCAN     Object owner=INV     Object name=MTL_PARAMETERS_U1     Cost=0     Cardinality=1     
           TABLE ACCESS BY INDEX ROWID     Object owner=GL     Object name=GL_CODE_COMBINATIONS     Cost=2     Cardinality=1     Bytes=57
            INDEX UNIQUE SCAN     Object owner=GL     Object name=GL_CODE_COMBINATIONS_U1     Cost=1     Cardinality=1     
          TABLE ACCESS BY INDEX ROWID     Object owner=INV     Object name=MTL_ITEM_LOCATIONS     Cost=3     Cardinality=1     Bytes=24
           INDEX RANGE SCAN     Object owner=INV     Object name=MTL_ITEM_LOCATIONS_U1     Cost=2     Cardinality=1     
         TABLE ACCESS BY INDEX ROWID     Object owner=HR     Object name=HR_ORGANIZATION_INFORMATION     Cost=2     Cardinality=1     Bytes=28
          INDEX RANGE SCAN     Object owner=HR     Object name=HR_ORGANIZATION_INFORMATIO_FK2     Cost=1     Cardinality=2     
        TABLE ACCESS BY INDEX ROWID     Object owner=HR     Object name=HR_ORGANIZATION_INFORMATION     Cost=1     Cardinality=1     Bytes=25
         INDEX RANGE SCAN     Object owner=HR     Object name=HR_ORGANIZATION_INFORMATIO_FK2     Cost=1     Cardinality=1     
       INDEX FULL SCAN     Object owner=GL     Object name=GL_SETS_OF_BOOKS_U2     Cost=1     Cardinality=1     Bytes=4
      BUFFER SORT               Cost=55     Cardinality=1     
       TABLE ACCESS FULL     Object owner=APPLSYS     Object name=FND_PRODUCT_GROUPS     Cost=3     Cardinality=1     

  • Help me to tune this pl/sql code...

    This code takes almost 3 minutes to execute....can you help where to improve?
    BEGIN                              
         DECLARE
             v_CntTextIdNotProcessed  NUMBER:=0;
                    BEGIN               
                       SELECT COUNT(1) INTO v_CntTextIdNotProcessed FROM COB_T_LT_TEXTID_SO_RECOMPILE WHERE IsProcessed = 0;
                       IF (v_CntTextIdNotProcessed > 0) THEN
                       BEGIN
                               INSERT INTO COB_T_LANG_TRANS_OPERATION
                                    OPERATIONID,
                                    OPERATIONCODE,
                                    OPERATIONREVISION,
                                    ISPROCESSED,                      
                                    CREATEDON,    
                                    CREATEDBY         
                            SELECT DISTINCT
                                    Id,
                                    OperationCode,
                                    OperationRevision,
                                    0,
                                    cob_f_getutc,
                                    'COB_WP_INS_LANG_TRANS_SO'                   
                            From
                                SELECT  Op.Id,Op.OperationCode,Op.OperationRevision
                                  FROM Function_ Fn
                                          INNER JOIN Function_Message Ft
                                              ON Ft.Functionid = Fn.Id
                                              AND Ft.Active    =1
                                              AND Fn.Active    =1
                                          INNER JOIN Text_Translation TT
                                              ON TT.Textid      = Ft.Textid
                                              AND TT.Active     =1
                                              AND (TT.Short    <> 'Null'
                                              OR TT.Medium     <> 'Null'
                                              OR TT.Extended   <> 'Null')
                                          INNER JOIN Function_Type Fnty
                                              ON Fn.Functiontype=Fnty.Functiontype
                                              AND Fnty.Active   =1
                                          INNER JOIN Operation_Step_Function Osf
                                              ON (Osf.Functionid=Fn.Id)
                                              AND Osf.Active    =1
                                          INNER JOIN Operation_Step Os
                                              ON Os.Id     =Osf.Operationstepid
                                              AND Os.Active=1
                                          INNER JOIN Operation Op
                                              ON Op.Id  = Os.Operationid
                                     -- AND op.defaultoperationrevision = 1
                                              AND Op.Active =1
                                              And Op.Revisionstatusid In (1,4)
                                              AND TO_CHAR(Op.Id) IN (SELECT DISTINCT TO_CHAR(SUBSTR(FPV.PropertyValue,INSTR(FPV.PropertyValue, '<PropertyBagItem Key="OperationID"><Value xsi:type="xsd:int">')+61,9))
                                                                FROM
                                                                       OPERATION OP
                                                                       INNER JOIN OPERATION_STEP OS ON Op.Id = OS.OperationId
                                                                       INNER JOIN OPERATION_STEP_FUNCTION OSF ON OS.Id = OSF.OperationStepId
                                                                       INNER JOIN   FUNCTION_ F ON OSF.FunctionId = F.id
                                                                       AND F.FunctionType = 21
                                                                       INNER JOIN FUNCTION_PROPERTY_VALUE FPV ON FPV.Functionid = F.Id  
                                                                WHERE UPPER(OP.OperationRevision) = 'WRAPPER')                                                                                                                       
                                  WHERE TT.TextID IN  (SELECT TextId FROM COB_T_LT_TEXTID_SO_RECOMPILE WHERE IsProcessed = 0)                                                               
                                  UNION                 
                                  SELECT Op.Id,Op.OperationCode,Op.OperationRevision
                                  FROM Function_Output Fo
                                      INNER JOIN Function_Output_Routing Forout
                                          ON Forout.Functionoutputid = Fo.Id
                                          INNER JOIN Text_Translation TT
                                          ON TT.Textid      = Forout.PromptTextid
                                          AND (TT.Short    <> 'Null'
                                          OR TT.Medium     <> 'Null'
                                          OR TT.Extended   <> 'Null')
                                      INNER JOIN Function_Output_Routing_Type Fort
                                          ON Fort.Id=Forout.Outputroutingtypeid
                                      INNER JOIN Text_Translation Ttdt
                                          ON Ttdt.Textid           = Fort.Textid
                                          AND Ttdt.Languageid      =1033
                                          AND Upper(Ttdt.Extended) = 'USER'
                                          INNER JOIN Function_ Fn
                                          ON Fn.Id = Fo.Functionid
                                      INNER JOIN Function_Type Fnty
                                          ON Fn.Functiontype=Fnty.Functiontype
                                      INNER JOIN Operation_Step_Function Osf
                                          ON (Osf.Functionid=Fn.Id)
                                      INNER JOIN Operation_Step Os
                                        ON Os.Id=Osf.Operationstepid
                                      INNER JOIN Operation Op
                                          ON Op.Id  = Os.Operationid
                                          And Op.Revisionstatusid In (1,4)
                                         AND to_char(Op.Id) IN (SELECT DISTINCT TO_CHAR(SUBSTR(FPV.PropertyValue,INSTR(FPV.PropertyValue, '<PropertyBagItem Key="OperationID"><Value xsi:type="xsd:int">')+61,9))
                                                                FROM
                                                                       OPERATION OP
                                                                       INNER JOIN OPERATION_STEP OS ON Op.Id = OS.OperationId
                                                                       INNER JOIN OPERATION_STEP_FUNCTION OSF ON OS.Id = OSF.OperationStepId
                                                                       INNER JOIN   FUNCTION_ F ON OSF.FunctionId = F.id
                                                                       AND F.FunctionType = 21
                                                                       INNER JOIN FUNCTION_PROPERTY_VALUE FPV ON FPV.Functionid = F.Id  
                                                                WHERE UPPER(OP.OperationRevision) = 'WRAPPER')
                                  WHERE  TT.TextID IN  (SELECT TextId FROM COB_T_LT_TEXTID_SO_RECOMPILE WHERE IsProcessed = 0)                                                                                                              
                                  UNION                 
                                SELECT Op.Id,Op.OperationCode,Op.OperationRevision
                                  FROM Function_Input Fi
                                      INNER JOIN Text_Translation TT
                                          ON ( TT.Textid    = Fi.Prompttextid
                                          AND TT.Active     =1)
                                          AND (TT.Short    <> 'Null'
                                          OR TT.Medium     <> 'Null'
                                          OR TT.Extended   <> 'Null')
                                      INNER JOIN Function_Input_Source_Type Fist
                                          ON Fist.Id     = Fi.Inputsourcetypeid
                                          AND Fist.Active=1
                                      INNER JOIN Text_Translation Ttdt
                                          ON Ttdt.Textid           = Fist.Textid
                                          AND Ttdt.Active          =1
                                          AND Ttdt.Languageid      = 1033
                                          AND Upper(Ttdt.Extended) = 'USER'
                                      INNER JOIN Function_ Fn
                                          ON Fn.Id     = Fi.Functionid
                                          AND Fn.Active=1
                                      INNER JOIN Function_Type Fnty
                                          ON Fn.Functiontype=Fnty.Functiontype
                                          AND Fnty.Active   =1
                                      INNER JOIN Operation_Step_Function Osf
                                          ON Osf.Functionid=Fn.Id
                                          AND Osf.Active   =1
                                      INNER JOIN Operation_Step Os
                                          ON Os.Id = Osf.Operationstepid
                                          AND Os.Active=1
                                      INNER JOIN Operation Op
                                         ON Op.Id = Os.Operationid
                                        AND Op.Active                =1
                                        And Op.Revisionstatusid In (1,4)
                                        AND TO_CHAR(Op.Id) IN (SELECT DISTINCT TO_CHAR(SUBSTR(FPV.PropertyValue,INSTR(FPV.PropertyValue, '<PropertyBagItem Key="OperationID"><Value xsi:type="xsd:int">')+61,9))
                                                                FROM
                                                                       OPERATION OP
                                                                       INNER JOIN OPERATION_STEP OS ON Op.Id = OS.OperationId
                                                                       INNER JOIN OPERATION_STEP_FUNCTION OSF ON OS.Id = OSF.OperationStepId
                                                                       INNER JOIN   FUNCTION_ F ON OSF.FunctionId = F.id
                                                                       AND F.FunctionType = 21
                                                                       INNER JOIN FUNCTION_PROPERTY_VALUE FPV ON FPV.Functionid = F.Id  
                                                                WHERE UPPER(OP.OperationRevision) = 'WRAPPER')                                                                                        
                                  WHERE  (TT.TextID IN  (SELECT TextId FROM COB_T_LT_TEXTID_SO_RECOMPILE WHERE IsProcessed = 0))                             
                                    UNION --Union Added by Yogesh
                                    SELECT Op.Id,Op.OperationCode,Op.OperationRevision
                                                                  FROM Function_Input Fi
                                                                      INNER JOIN Text_Translation TT
                                                                          ON ( TT.Textid    = Fi.Prompttextid
                                                                          AND TT.Active     =1)
                                                                          AND (TT.Short    <> 'Null'
                                                                          OR TT.Medium     <> 'Null'
                                                                          OR TT.Extended   <> 'Null')
                                                                      INNER JOIN Function_Input_Source_Type Fist
                                                                          ON Fist.Id     = Fi.Inputsourcetypeid
                                                                          AND Fist.Active=1
                                                                      INNER JOIN Text_Translation Ttdt
                                                                          ON Ttdt.Textid           = Fist.Textid
                                                                          AND Ttdt.Active          =1
                                                                          AND Ttdt.Languageid      = 1033
                                                                          AND Upper(Ttdt.Extended) = 'USER'
                                                                      INNER JOIN Function_ Fn
                                                                          ON Fn.Id     = Fi.Functionid
                                                                          AND Fn.Active=1
                                                                      INNER JOIN Function_Type Fnty
                                                                          ON Fn.Functiontype=Fnty.Functiontype
                                                                          AND Fnty.Active   =1
                                                                      INNER JOIN Operation_Step_Function Osf
                                                                          ON Osf.Functionid=Fn.Id
                                                                          AND Osf.Active   =1
                                                                      INNER JOIN Operation_Step Os
                                                                          ON Os.Id = Osf.Operationstepid
                                                                          AND Os.Active=1
                                                                      INNER JOIN Operation Op
                                                                         ON Op.Id = Os.Operationid                                
                                                                        AND Op.Active                =1
                                                                        And Op.Revisionstatusid In (1,4)
                                                                       INNER JOIN FUNCTION_INPUT_VALUE Fiv                 
                                                                            ON  Fi.id = Fiv.functionInputId AND Fiv.textid IS NOT NULL
                                                                        AND TO_CHAR(Op.Id) IN (SELECT DISTINCT TO_CHAR(SUBSTR(FPV.PropertyValue,INSTR(FPV.PropertyValue, '<PropertyBagItem Key="OperationID"><Value xsi:type="xsd:int">')+61,9))
                                                                                                FROM
                                                                                                       OPERATION OP
                                                                                                       INNER JOIN OPERATION_STEP OS ON Op.Id = OS.OperationId
                                                                                                       INNER JOIN OPERATION_STEP_FUNCTION OSF ON OS.Id = OSF.OperationStepId
                                                                                                       INNER JOIN   FUNCTION_ F ON OSF.FunctionId = F.id
                                                                                                       AND F.FunctionType = 21
                                                                                                       INNER JOIN FUNCTION_PROPERTY_VALUE FPV ON FPV.Functionid = F.Id  
                                                                                                WHERE UPPER(OP.OperationRevision) = 'WRAPPER')                                                                                        
                                                                  WHERE  (Fiv.TextID  IN  (SELECT TextId FROM COB_T_LT_TEXTID_SO_RECOMPILE WHERE IsProcessed = 0 ) )   
                                  MINUS
                                         (SELECT OperationId ,OperationCode,OperationRevision From COB_T_LANG_TRANS_OPERATION WHERE IsProcessed = 0)                                                                                    
                            DELETE FROM COB_T_LT_TEXTID_SO_RECOMPILE  where  IsProcessed = 0;        
                       END;         
                       END IF;                                       
    --            EXCEPTION
    --               WHEN OTHERS THEN
    --               ROLLBACK;
    --                   RAISE_APPLICATION_ERROR(-20660 , 'Concurrency violation. COB_T_LANG_TRANS_OPERATION table changed by another user in the meantime.');
                   END;                    
            END;          
    END;
    /

    Do you remember this thread of yours? {message:id=10653623}
    Well, you were asked to read various FAQs and to post certain information.
    You haven't read and you didn't post the required information.
    If you want people to make the effort to help you, you need to make the effort to post
    the required information.

  • I have problem with account that i can't make update or buy from app store There is massage appear in my payment page that i must contact with i tunes support to complete this transaction Please help me to fixe this problem as soon possible Hany hassan 00

    I have problem with account that i can't make update or buy from app store
    There is massage appear in my payment page that i must contact with i tunes support to complete this transaction
    Please help me to fixe this problem as soon possible
    Hany hassan
    0096597617317
    0096596677186
    Thank you

    You need to Contact iTunes Support...
    Apple  Support  iTunes Store  Contact Us

  • Please help me to solve this date comparision issue..

    Please help me to solve this issue..
    If i have some data like the following..
    ID           START DATE             END DATE
    1             20080101              20080501
    1             20080502              20080630
    2             20080631              20080801
    2             20080802              20080901
                                                 ---------------> There is a break in date over here
    2             20080930              20081029
    2             20081030              20081130
    I need to compare the End Date with the start date (These data will not be in order)
    and find out if there is any break and should get the output date : *20080930*
    I am trying to do this in SQL or PL/SQL.Please help me .
    Thanks in advance.
    phani

    Hi Frank ,
    Sorry to bug you again. I ran your code on my actual data but not gettting the expected output.Here i am posting the actual code and the output that i got when i ran your code.Please bear with me and help me to solve this..
    /* Formatted on 5/25/2009 2:27:24 PM (QP5 v5.115.810.9015) */
    SELECT   member_nbr,
             aff_nbr,
             ymdeff,
             ymdend,
             gap_before,
             COUNT (gap_after)
                OVER (PARTITION BY member_nbr, aff_nbr ORDER BY ymdend DESC)
                AS gap_cnt
      FROM   (SELECT   member_nbr,
                       aff_nbr,
                       ymdeff,
                       ymdend,
                       CASE
                          WHEN ymdeff >
                                  LEAD(ymdend)
                                     OVER (PARTITION BY member_nbr, aff_nbr
                                           ORDER BY ymdend DESC)
                                  + 1
                          THEN
                             1
                       END
                          AS gap_before,
                       CASE
                          WHEN ymdend <
                                  LAG(ymdeff)
                                     OVER (PARTITION BY member_nbr, aff_nbr
                                           ORDER BY ymdend DESC)
                                  - 1
                          THEN
                             1
                       END
                          AS gap_after
    ------------I need this SQL to filter the whole data to the data that i posted in previous post -----
                FROM   (  SELECT   ms1.member_nbr, 
                                   ms1.aff_nbr,
                                   ms1.ymdeff,
                                   ms1.ymdend,
                                   ms1.void
                            FROM   (SELECT   ms.member_nbr,
                                             ms.aff_nbr,
                                             ms.ymdeff,
                                             ms.ymdend,
                                             ms.void
                                      FROM   MEMBER mb, member_span ms
                                     WHERE   mb.member_nbr = ms.member_nbr
                                             AND (20090523 BETWEEN ms.ymdeff
                                                               AND  ms.ymdend
                                                  AND TRIM (void) IS NULL)
                                             AND mb.member_nbr = 'A1000073000 ')
                                   eff_pcp,
                                   member_span ms1
                           WHERE   ms1.member_nbr = eff_pcp.member_nbr
                                   AND (SUBSTR (eff_pcp.aff_nbr, 1, 6) =
                                           SUBSTR (ms1.aff_nbr, 1, 6))
                        ORDER BY   ms1.ymdeff DESC)
    ---------- end of my part  ----------
                table_x) got_gaps;Outputs that i got when i ran that code for each individual members..
    Sorry to bug you frank and thanks for all the help.I will post here if i get any other data.
    Thanks
    phani

  • Please help me in doing this

    hi,
    I'm new for the JSP and got struck at this point .
    I have a JSP page wherein it consists of a table and the servlet that retrieves the data from the DB(MY SQL). Now i need to fill the contents of the table as mentioned below.
    First 5 rows must get printed then upon clicking the next button the next five rows must be filled.....and so on......
    Please help me in reaching this requirement.
    JSP CODE:
    <%@ page import="java.io.*" %>
    <%@ page import="java.lang.*" %>
    <%@ page import="java.util.*" %>
    <html>
    <head><title> TOP USERS </title>
    </head>
    <body bgcolor="c0c0c0">
    <div align="center">
    <table>
    <tr bgcolor="white"><td> <font color="red" size="5"><b>TOP  USERS </b> </font></td></tr>
    </table>
    </div>
    <div align="center">
    <form name="top">
    <font face="verdana">
    Report for TOP
    <select name="users">
    <option value="5">5
    <option value="10">10
    <option value="15">15
    </select>
    Users
    <br> <br>
    <% ArrayList list=new ArrayList();
    list=(ArrayList)request.getAttribute("TOPUSERS");
    %>
    <table border="1" align="center" width=35%>
    <tr>
      <td align="center"><b> Name </b> </td>
      <td align="center"> <b> Phone # </b> </td>
    </tr>
    <%
      int cnt=10;
      if(cnt!=0)
      for(int i=0; i<cnt; i++)
    %>
    <tr>
    <td align="left"> <% out.println(list.get(i));
                         i++; %>
    </td>
    <td align="right"> <% out.println(list.get(i));%>
    </td>
    </tr>
    <% }
      }  %>
    </table>
    <table border="0" align="center" width=35% >
    <tr><td align="right"> <input type="submit" value="next" name="next" onclick="return cnt+=10"> </td> </tr>
    </table>
    </font>
    </form>
    </div>
    </body>
    </html>Please correct the above code......
    sorry if my code is wrong........
    Here i can print the all the rows at once but i'm not able to pring in 5 rows and upon the clik of next the next five rows........

    Pass it as a hidden parameter.

  • My iPhone 6 ear speaker is not working properly I couldn't able to hear any thing from ear speaker to lissen I had to put on loud speaker or to use handsfree please help me out with this problem if some body have answer?

    My iPhone 6 ear speaker is not working properly I couldn't able to hear any thing from ear speaker to listen I had to put on loud speaker or to use hands free please help me out with this problem if some body have answer?

    Hi Venkata from NZ,
    If you are having an issue with the speaker on your iPhone, I would suggest that you troubleshoot using the steps in this article - 
    If you hear no sound or distorted sound from your iPhone, iPad, or iPod touch speaker - Apple Support
    Thanks for using Apple Support Communities.
    Best,
    Brett L 

  • I have unabled 5 fingure gesture now not able to perform any task,also my power button is not working,please help me in removing this gesture,using I phone 4

    I have unabled 5 fingure gesture now not able to perform any task,also my power button is not working,please help me in removing this gesture,using I phone 4

    I have unabled 5 fingure gesture now not able to perform any task,also my power button is not working,please help me in removing this gesture,using I phone 4

  • Hello i have a unusual problem,anyway my iphone 4 wont turn on and when someone calls they hear ringing,but my phone doesent ring,so i open cimcas now ring off. Screen is just black,because it's turned off..Please help me to solve this problem..Thanks

    Hello i have a unusual problem,anyway my iphone 4 wont turn on and when  someone calls they hear ringing,but my phone doesent ring.So i poen simcase and now ring off. Screen is just  black,because it's turned off..Please help me to solve this  problem..Thanks

    As far as trying to power up your device, make sure it has a good charge and then hold the button on the top of the phone and the home button on the faceplate together until the apple appears on the screen.

  • Hi, when ever I'm using 3G, on my Iphone4 sim stops working and Network is lost, this started after I updated my phone with  6.0.1(10A523)version. Please help how to solve this problem.

    Hi, when ever I'm using 3G, on my Iphone4 sim stops working and network is lost, this started after I updated my phone with  6.0.1(10A523)version. Please help how to solve this problem. Thanks.

    Photos/videos in the Camera Roll are not synced. Photos/videos in the Camera Roll are not touched with the iTunes sync process. Photos/videos in the Camera Roll can be imported by your computer which is not handled by iTunes. Most importing software includes an option to delete the photos/videos from the Camera Roll after the import process is complete. If is my understanding that some Windows import software supports importing photos from the Camera Roll, but not videos. Regardless, the import software should not delete the photos/videos from the Camera Roll unless you set the app to do so.
    Photos/videos in the Camera Roll are included with your iPhone's backup. If you synced your iPhone with iTunes before the videos on the Camera Roll went missing and you haven't synced your iPhone with iTunes since they went missing, you can try restoring the iPhone with iTunes from the iPhone's backup. Don't sync the iPhone with iTunes again and decline the prompt to update the iPhone's backup after selecting Restore.

  • HT1212 My iPod touch is disabled after too many attempts and I want to enable it without getting it clear so can you please help me out in this....

    My iPod touch is disabled after too many attempts and I want to enable it without getting it clear so can you please help me out in this....

    A data recovery company MAY be able to do it for a price. The Disabled is a very good security feature.
    JWhy not just restore from the last backup you have?
    Place the iOS device in Recovery Mode and then connect to your computer and restore via iTunes. The iPod will be erased.
    iOS: Wrong passcode results in red disabled screen                         
    If recovery mode does not work try DFU mode.                        
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings        
    For how to restore:
    iTunes: Restoring iOS software
    To restore from backup see:
    iOS: How to back up     
    If you restore from iCloud backup the apps will be automatically downloaded. If you restore from iTunes backup the apps and music have to be in the iTunes library since synced media like apps and music are not included in the backup of the iOS device that iTunes makes.
    You can redownload most iTunes purchases by:
      Downloading past purchases from the App Store, iBookstore, and iTunes Store

  • TS1363 My iPod Nano 7th Generation couldn't be detected by iTunes when I plugged in. I tried resolving the issue by uninstalling the iTunes and then install it back again but yet still the same problem exist. Can you please help me to solve this issue?

    My iPod Nano 7th Generation couldn't be detected by iTunes when I plugged in. I tried resolving the issue by uninstalling the iTunes and then install it back again but yet still the same problem exist. Can you please help me to solve this issue? I have already updated to the latest version of iTunes on my Windows 8 and I cannot synchronize my iPod for the time being. Please do help me to solve this problem. Thank You.

    uninstall all iTunes,5 programes,this worked for me after reinstall them

  • Can you please help me how resolved this issue.

    Hi Experts
    I am trying to connect LDAP by R/3 system. R/3 system connected to LDAP but when I am trying to find and pull the fileds in the "Find in the Directolry" option I am getting below error.
    LDAPRC 010 another server is referenced.
    Can you please help me how resolved this issue.
    With Regards,
    Trinadh Bokka

    You may be able to solve by using
    Note 1151329 - Depth of LDAP search is only one level below the base entry
    Markus

  • While opening the iTune Store i receive the following error, "The procedure entry point ADAdPolicyEngine_DidEnterSation could not be located in the dynamic link library iAdCore.dll" Please help me to clear this error.

    While opening the iTune Store i receive the following error, "The procedure entry point ADAdPolicyEngine_DidEnterSation could not be located in the dynamic link library iAdCore.dll" Please help me to clear this error.

    I faced the same issue. This solved it for me: Troubleshooting issues with iTunes for Windows updates
    Hope this helps.

  • HT204266 I lost the app "app store" on my iphone. How to get it back? I couldn't find a way neither on the iphone mor on iTunes Could you please help me in restore this app? Thanks

    I lost the app "app store" on my iphone. How to get it back? I couldn't find a way neither on the iphone mor on iTunes Could you please help me in restore this app? Thanks

    The App store is a iOS function and cannot be deleted. Try checking other home screens/folders and see if you can locate it. If not, go into Settings>General>Reset>Reset Home Screen Layout.

Maybe you are looking for

  • SetBackground() Is Not Working in Windows 7

    It looks like inheritance is broken in the component hierarchy for JFrame in Windows 7 JDK 1.6.0_23-b05. Run this code to reproduce the issue. public class Main public static void main(String[] args) JFrame frame = new JFrame(); frame.setTitle("Test

  • How can I know the number of ejb instances

    Hi all, We need to know how can we get the number of ejb instances (entity and session) while the application is running. We have a memory leak, so we need to know the amount opf memory used. Please, it´s quite urgent, can anybody help us? It seems

  • Previous weeks data

    Hi all, I have a requirement where I need to show the Unbilled amount of this week as well as last 20 weeks based on region. Let say I am on fiscal week 20. Now if create a report based on region and Unbilled amount I will get $ 20 for europe. Now if

  • How to batch convert music?

    Hey everybody! Just a quick question here How do you batch convert your library completely to Mp3 or completely to AAC? I have a library full of different bitrate mp3s and aacs and i wanted them to be completely uniform. Any ideas oh how to do this?

  • Who's going to be at Networkers in Las Vegas?

    Curious to know who's going to be at Networkers in Las Vegas this year?  If you are, drop a post here or send me a private message via the forums.  I'll be there along with a number of my fellow Chesapeake NetCraftsmen and we'd be love to put faces t