Recursion in pl/sql

Hi all,
I need to find out all the nested procedure or functions list which are invoked by a particular procedure or function.I am trying to write code which I am using recursion.I am facing problem in storing values in INTO clause of the SELECT statement because multiple procs can not be stored on one index i.e proclist_v(i).Should I use any other type of object other than pl/sql table.please give me an idea
CREATE OR REPLACE PACKAGE finddblink_pack
IS
TYPE NameType IS TABLE OF
dba_dependencies.referenced_name%TYPE
INDEX BY BINARY_INTEGER;
PROCEDURE finddblink_proc (proc_par NameType)
END finddblink_pack;
CREATE OR REPLACE PACKAGE BODY finddblink_pack
IS
PROCEDURE finddblink_proc (proc_par NameType)
IS
proclist_v NameType;
BEGIN
FOR i in func_par.FIRST .. func_par.LAST LOOP
SELECT referenced_name
INTO proclist_v(i)
FROM dba_dependencies
WHERE name=upper(func_par(i))
AND referenced_type in('FUNCTION','PROCEDURE','PACKAGE BODY');
finddblink(proclist_v);
END LOOP;
END finddblink_proc;
END finddblink_pack;

Well, you do not need recursive plsql for that. Hierarchical SQL will do:
SQL> CREATE OR REPLACE
  2    PROCEDURE P1
  3      IS
  4      BEGIN
  5          NULL;
  6  END;
  7  /
Procedure created.
SQL> CREATE OR REPLACE
  2    PROCEDURE P2
  3      IS
  4      BEGIN
  5          P1;
  6  END;
  7  /
Procedure created.
SQL> CREATE OR REPLACE
  2    PROCEDURE P3
  3      IS
  4      BEGIN
  5          P2;
  6  END;
  7  /
Procedure created.
SQL> SELECT  referenced_name
  2    FROM  dba_dependencies
  3    START WITH name = 'P3'
  4    CONNECT BY prior referenced_name = name
  5    AND referenced_type in('FUNCTION','PROCEDURE','PACKAGE BODY')
  6  /
REFERENCED_NAME
P2
P1
SQL> SY.

Similar Messages

  • ็็How can i use multiple recursive in sql ?

    I have 2 tables  which have each with cte itself
    For position Table
    CREATE TABLE [Dep](
    [Depid] [int] NULL,
    [DepName] [nvarchar](50) NULL,
    [Depparent] [int] NULL
    INSERT [dbo].[Position] ([poid], [poname], [poparent], [Depid]) VALUES (1, N'saleLeader', NULL, 3)
    INSERT [dbo].[Position] ([poid], [poname], [poparent], [Depid]) VALUES (2, N'PurLeader', NULL, 1)
    INSERT [dbo].[Position] ([poid], [poname], [poparent], [Depid]) VALUES (3, N'sale1', 1, 3)
    INSERT [dbo].[Position] ([poid], [poname], [poparent], [Depid]) VALUES (4, N'Pur1', 2, 1)
    INSERT [dbo].[Position] ([poid], [poname], [poparent], [Depid]) VALUES (5, N'ProductionLeader', NULL, 4)
    INSERT [dbo].[Position] ([poid], [poname], [poparent], [Depid]) VALUES (6, N'Pro1', 5, 4)
    INSERT [dbo].[Position] ([poid], [poname], [poparent], [Depid]) VALUES (7, N'Pro2', 5, 4)
    WITH EmpCTE( poid , poname , poparent , Depid  , lvl)
    AS
      SELECT poid , poname , poparent , Depid  , 0
      FROM Position
      UNION ALL
      SELECT  E.poid  , E.poname , E.poparent , e.Depid   , lvl+1
      FROM Position AS E
        JOIN EmpCTE AS M
          ON E.poparent = M.poid
    SELECT * FROM EmpCTE
    For Dep Table
    CREATE TABLE [Dep](
    [Depid] [int] NULL,
    [DepName] [nvarchar](50) NULL,
    [Depparent] [int] NULL
    INSERT [dbo].[Dep] ([Depid], [DepName], [Depparent]) VALUES (1, N'Admin', 7)
    INSERT [dbo].[Dep] ([Depid], [DepName], [Depparent]) VALUES (2, N'Pur', 1)
    INSERT [dbo].[Dep] ([Depid], [DepName], [Depparent]) VALUES (3, N'Sale', 1)
    INSERT [dbo].[Dep] ([Depid], [DepName], [Depparent]) VALUES (4, N'Manufac', 7)
    INSERT [dbo].[Dep] ([Depid], [DepName], [Depparent]) VALUES (5, N'Production1', 4)
    INSERT [dbo].[Dep] ([Depid], [DepName], [Depparent]) VALUES (6, N'finishing1', 4)
    INSERT [dbo].[Dep] ([Depid], [DepName], [Depparent]) VALUES (7, N'MD', NULL)
    WITH EmpCTE( depid , depname , depparent  , lvl)
    AS
      SELECT depid , depname , depparent  , 0
      FROM Dep
      UNION ALL
      SELECT  E.depid  , E.depname , E.depparent , lvl+1
      FROM Dep AS E
        JOIN EmpCTE AS M
          ON E.depparent = M.depid
    SELECT * FROM EmpCTE
    The table position has a depid column which join to Dep datable.
    I want to put position level  in dep level.
    Like if  at positin level 0 must be under dep.

    Please see this link:
    CTEs with Multiple Recursive Members
    T-SQL Articles
    T-SQL e-book by TechNet Wiki Community
    T-SQL blog

  • SQL with connect by prior running for a long time

    Hi,
    We are using Oracle 10g. Below is a cursor sql which is having performance issues. The pAccountid is being passed from the output of a different cursor. But this cursor sql is running for a long time. Could you please help me in tuning this sql. I believe the subquery with connect by prior is causing the trouble.
    The TRXNS is a huge table which is not partitioned. The query is forced to use the index on the accountid of the TRXNS table.
    The accountlink table has 20,000 records and the TRXNStrack table has 10,000 records in total.
    This sql executes for 200,000 pAccountids and runs for more than 8 hours.
    SELECT /*+ INDEX(T TRXNS_ACCOUNTID_NIDX) */ AL.FROMACCOUNTID oldaccountid ,
                                    A.ACCOUNTNUM  oldaccountnum,
                                   T.TRXNSID,
                                   T.TRXNSTYPEID,
                                   T.DESCRIPTION ,
                                   T.postdt,
                                   T.TRXNSAMT
                        FROM
                        ACCOUNTLINK AL,
                        TRXNS T,
                        ACCOUNT A
                       WHERE AL.TOACCOUNTID IN
                                                             (SELECT TOACCOUNTID FROM ACCOUNTLINK START WITH TOACCOUNTID = pAccountid
                                                                                                                         CONNECT BY PRIOR FROMACCOUNTID  = TOACCOUNTID)
                            AND AL.FROMACCOUNTID = T.ACCOUNTID
                            AND A.ACCOUNTID = AL.FROMACCOUNTID
    AND NOT EXISTS (select 1 from TRXNStrack trck where trck.TRXNSid = t.TRXNSid AND TRXNSTrackReasonid = 1)
                            AND T.postdt > A.CLOSEDATE
                            AND T.postdt >= sysdate-2
                            AND T.postdt <= sysdate;
    Create script for trxn table:
    CREATE TABLE SP.TRXNS
      TRXNSID      NUMBER(15) CONSTRAINT "BIN$rpIQEeyLDfbgRAAUT4DEnQ==$0" NOT NULL,
      ACCOUNTID    NUMBER(15) CONSTRAINT "BIN$rpIQEeyMDfbgRAAUT4DEnQ==$0" NOT NULL,
      STATEMENTID  NUMBER(15),
      TRXNSTYPEID  NUMBER(15),
      DESCRIPTION  VARCHAR2(80 BYTE),
      postdt     DATE,
      TRXNSAMT     NUMBER(12,2),
      TRXNSREQID   NUMBER(15),
      LASTUPDATE   DATE,
      SOURCEID     NUMBER(15),
      HIDE         VARCHAR2(1 BYTE)
    TABLESPACE SO_TRXN_DATA
    RESULT_CACHE (MODE DEFAULT)
    PCTUSED    40
    PCTFREE    10
    INITRXNS   2
    MAXTRXNS   255
    STORAGE    (
                INITIAL          50M
                NEXT             1M
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                FREELISTS        8
                FREELIST GROUPS  1
                BUFFER_POOL      DEFAULT
                FLASH_CACHE      DEFAULT
                CELL_FLASH_CACHE DEFAULT
    LOGGING
    NOCOMPRESS
    NOCACHE
    NOPARALLEL
    MONITORING;
    CREATE INDEX SP.TRXNS_ACCOUNTID_NIDX ON SP.TRXNS
    (ACCOUNTID, postdt)
    LOGGING
    TABLESPACE SO_TRXN_INDEX
    PCTFREE    10
    INITRXNS   2
    MAXTRXNS   255
    STORAGE    (
                INITIAL          64K
                NEXT             1M
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                FREELISTS        1
                FREELIST GROUPS  1
                BUFFER_POOL      DEFAULT
                FLASH_CACHE      DEFAULT
                CELL_FLASH_CACHE DEFAULT
    NOPARALLEL;
    below is the executing plan for this sql taken from toad :
    PLAN_ID
    TIMESTAMP
    OPERATION
    OPTIONS
    OBJECT_OWNER
    OBJECT_NAME
    OBJECT_ALIAS
    OBJECT_INSTANCE
    OBJECT_TYPE
    OPTIMIZER
    SEARCH_COLUMNS
    ID
    PARENT_ID
    DEPTH
    POSITION
    COST
    CARDINALITY
    BYTES
    CPU_COST
    IO_COST
    TEMP_SPACE
    ACCESS_PREDICATES
    FILTER_PREDICATES
    PROJECTION
    TIME
    QBLOCK_NAME
    1121
    9/10/2013 3:30
    FILTER
    1
    0
    1
    1
    NOT EXISTS (SELECT 0 FROM "TRXNSTRACK" "TRCK" WHERE "TRXNSTRACKREASONID"=1 AND "TRCK"."TRXNSID"=:B1)
    AL."FROMACCOUNTID"[NUMBER,22], "T"."TRXNSID"[NUMBER,22], "T"."TRXNSTYPEID"[NUMBER,22], "T"."DESCRIPTION"[VARCHAR2,80], "T"."POSTDT"[DATE,7], "T"."TRXNSAMT"[NUMBER,22], "A"."ACCOUNTNUM"[VARCHAR2,19]
    SEL$5DA710D3
    1121
    9/10/2013 3:30
    FILTER
    2
    1
    2
    1
    SYSDATE@!-2<=SYSDATE@!
    AL."FROMACCOUNTID"[NUMBER,22], "T"."TRXNSID"[NUMBER,22], "T"."TRXNSTYPEID"[NUMBER,22], "T"."DESCRIPTION"[VARCHAR2,80], "T"."POSTDT"[DATE,7], "T"."TRXNSAMT"[NUMBER,22], "A"."ACCOUNTNUM"[VARCHAR2,19]
    1121
    9/10/2013 3:30
    NESTED LOOPS
    3
    2
    3
    1
    (#keys=0) "AL"."FROMACCOUNTID"[NUMBER,22], "T"."TRXNSID"[NUMBER,22], "T"."TRXNSTYPEID"[NUMBER,22], "T"."DESCRIPTION"[VARCHAR2,80], "T"."POSTDT"[DATE,7], "T"."TRXNSAMT"[NUMBER,22], "A"."ACCOUNTNUM"[VARCHAR2,19]
    1121
    9/10/2013 3:30
    NESTED LOOPS
    4
    3
    4
    1
    5
    1
    119
    3989858
    4
    (#keys=0) "AL"."FROMACCOUNTID"[NUMBER,22], "T"."TRXNSID"[NUMBER,22], "T"."TRXNSTYPEID"[NUMBER,22], "T"."DESCRIPTION"[VARCHAR2,80], "T"."POSTDT"[DATE,7], "T"."TRXNSAMT"[NUMBER,22], "A".ROWID[ROWID,10]
    1
    1121
    9/10/2013 3:30
    NESTED LOOPS
    5
    4
    5
    1
    4
    1
    90
    3989690
    3
    (#keys=0) "AL"."FROMACCOUNTID"[NUMBER,22], "T"."TRXNSID"[NUMBER,22], "T"."TRXNSTYPEID"[NUMBER,22], "T"."DESCRIPTION"[VARCHAR2,80], "T"."POSTDT"[DATE,7], "T"."TRXNSAMT"[NUMBER,22]
    1
    1121
    9/10/2013 3:30
    HASH JOIN
    SEMI
    6
    5
    6
    1
    3
    2
    54
    3989094
    2
    AL."TOACCOUNTID"="TOACCOUNTID"
    (#keys=1) "AL"."FROMACCOUNTID"[NUMBER,22]
    1
    1121
    9/10/2013 3:30
    INDEX
    FULL SCAN
    SP
    ACCOUNTLINK_AK1
    AL@SEL$1
    INDEX (UNIQUE)
    ANALYZED
    7
    6
    7
    1
    1
    18
    252
    107
    1
    AL."FROMACCOUNTID"[NUMBER,22], "AL"."TOACCOUNTID"[NUMBER,22]
    1
    SEL$5DA710D3
    1121
    9/10/2013 3:30
    VIEW
    SYS
    VW_NSO_1
    VW_NSO_1@SEL$5DA710D3
    11
    VIEW
    8
    6
    7
    2
    2
    18
    234
    107
    1
    TOACCOUNTID[NUMBER,22]
    1
    SEL$683B0107
    1121
    9/10/2013 3:30
    CONNECT BY
    NO FILTERING WITH START-WITH
    9
    8
    8
    1
    TOACCOUNTID=PRIOR "FROMACCOUNTID"
    TOACCOUNTID=56354162
    TOACCOUNTID[NUMBER,22], "FROMACCOUNTID"[NUMBER,22], PRIOR NULL[22], LEVEL[4]
    SEL$683B0107
    1121
    9/10/2013 3:30
    INDEX
    FULL SCAN
    SP
    ACCOUNTLINK_AK1
    ACCOUNTLINK@SEL$3
    INDEX (UNIQUE)
    ANALYZED
    10
    9
    9
    1
    1
    18
    252
    107
    1
    ACCOUNTLINK.ROWID[ROWID,10], "FROMACCOUNTID"[NUMBER,22], "TOACCOUNTID"[NUMBER,22]
    1
    SEL$3
    1121
    9/10/2013 3:30
    TABLE ACCESS
    BY INDEX ROWID
    SP
    TRXNS
    T@SEL$1
    2
    TABLE
    ANALYZED
    11
    5
    6
    2
    1
    1
    63
    298
    1
    T."TRXNSID"[NUMBER,22], "T"."TRXNSTYPEID"[NUMBER,22], "T"."DESCRIPTION"[VARCHAR2,80], "T"."POSTDT"[DATE,7], "T"."TRXNSAMT"[NUMBER,22]
    1
    SEL$5DA710D3
    1121
    9/10/2013 3:30
    INDEX
    RANGE SCAN
    SP
    TRXNS_ACCOUNTID_NIDX
    T@SEL$1
    INDEX
    ANALYZED
    2
    12
    11
    7
    1
    1
    1
    224
    1
    AL."FROMACCOUNTID"="T"."ACCOUNTID" AND "T"."POSTDT">=SYSDATE@!-2 AND "T"."POSTDT"<=SYSDATE@!
    T.ROWID[ROWID,10], "T"."POSTDT"[DATE,7]
    1
    SEL$5DA710D3
    1121
    9/10/2013 3:30
    INDEX
    UNIQUE SCAN
    SP
    ACCOUNT_PK
    A@SEL$1
    INDEX (UNIQUE)
    ANALYZED
    1
    13
    4
    5
    2
    1
    1
    90
    1
    A."ACCOUNTID"="AL"."FROMACCOUNTID"
    A.ROWID[ROWID,10]
    1
    SEL$5DA710D3
    1121
    9/10/2013 3:30
    TABLE ACCESS
    BY INDEX ROWID
    SP
    ACCOUNT
    A@SEL$1
    3
    TABLE
    ANALYZED
    14
    3
    4
    2
    1
    1
    29
    168
    1
    A."CLOSEDATE"<SYSDATE@! AND "T"."POSTDT">"A"."CLOSEDATE"
    A."ACCOUNTNUM"[VARCHAR2,19]
    1
    SEL$5DA710D3
    1121
    9/10/2013 3:30
    INDEX
    RANGE SCAN
    SP
    TRXNSTRACK_TRXNSID_NIDX
    TRCK@SEL$6
    INDEX
    ANALYZED
    2
    15
    1
    2
    2
    1
    1
    10
    73
    1
    TRCK."TRXNSID"=:B1 AND "TRXNSTRACKREASONID"=1
    TRCK."TRXNSID"[NUMBER,22], "TRXNSTRACKREASONID"[NUMBER,22]
    1
    SEL$6
    Please help me in debugging this thanks!

    Hi,
    Thanks for your thought on this subject. Below is the trace info that I got from the DBA
    SQL ID: d0x879qx2zgtz Plan Hash: 4036333519
    SELECT /*+ INDEX(T TRXNS_ACCOUNTID_NIDX) */ AL.FROMACCOUNTID OLDACCOUNTID ,
      A.ACCOUNTNUM OLDACCOUNTNUM, T.TRXNSID, T.TRXNSTYPEID, T.DESCRIPTION ,
      T.POSTDT, T.TRXNSAMT
    FROM
    ACCOUNTLINK AL, TRXNS T, ACCOUNT A WHERE AL.TOACCOUNTID IN (SELECT
      TOACCOUNTID FROM ACCOUNTLINK START WITH TOACCOUNTID = :B3 CONNECT BY PRIOR
      FROMACCOUNTID = TOACCOUNTID) AND AL.FROMACCOUNTID = T.ACCOUNTID AND
      A.ACCOUNTID = AL.FROMACCOUNTID AND NOT EXISTS (SELECT 1 FROM TRXNSTRACK
      TRCK WHERE TRCK.TRXNSID = T.TRXNSID AND TRXNSTRACKREASONID = :B4 ) AND
      T.POSTDT > A.CLOSEDATE AND T.POSTDT >= :B2 AND T.POSTDT <= :B1
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        0      0.00       0.00          0          0          0           0
    Execute  17160      2.10       1.87          0          0          0           0
    Fetch    17160   7354.61    7390.86     169408    5569856  883366791           0
    total    34320   7356.71    7392.74     169408    5569856  883366791           0
    Misses in library cache during parse: 0
    Optimizer mode: CHOOSE
    Parsing user id: 38     (recursive depth: 1)
    SQL ID: gs89hpavb4cts Plan Hash: 3415795327
    SELECT A.ACCOUNTID, C.MEMBERID, A.PROGRAMID, A.ACCOUNTNUM
    FROM
    CUSTOMER C, CUSTOMERACCOUNT CA, ACCOUNT A, PROGRAMPARAMVALUE PPV,
      BATCHPROCESSPROGRAM BP WHERE A.PROGRAMID = BP.PROGRAMID AND A.PROGRAMID =
      PPV.PROGRAMID AND A.ACCOUNTID = CA.ACCOUNTID AND CA.PERSONID = C.PERSONID
      AND PPV.PARAMID = :B2 AND PPV.VALUE = 'Y' AND BP.PROCESSID = :B1 AND BP.RUN
      = 'Y' AND A.ACCOUNTTYPEID = 4 AND A.ACCOUNTSTATUSID = 1 AND C.MEMBERID IS
      NOT NULL
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        0      0.00       0.00          0          0          0           0
    Execute      0      0.00       0.00          0          0          0           0
    Fetch      172     13.14     115.34      80826     278650          0       17200
    total      172     13.14     115.34      80826     278650          0       17200
    Misses in library cache during parse: 0
    Parsing user id: 38     (recursive depth: 1)
    OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        0      0.00       0.00          0          0          0           0
    Execute      0      0.00       0.00          0          0          0           0
    Fetch        0      0.00       0.00          0          0          0           0
    total        0      0.00       0.00          0          0          0           0
    Misses in library cache during parse: 0
    OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        0      0.00       0.00          0          0          0           0
    Execute  17160      2.10       1.87          0          0          0           0
    Fetch    17332   7367.75    7506.21     250234    5848506  883366791       17200
    total    34492   7369.85    7508.09     250234    5848506  883366791       17200
    Misses in library cache during parse: 0
        2  user  SQL statements in session.
        0  internal SQL statements in session.
        2  SQL statements in session.
    Trace file: svoprod_ora_12346.trc
    Trace file compatibility: 11.1.0.7
    Sort options: default
           1  session in tracefile.
           2  user  SQL statements in trace file.
           0  internal SQL statements in trace file.
           2  SQL statements in trace file.
           2  unique SQL statements in trace file.
       66499  lines in trace file.
        7516  elapsed seconds in trace file.

  • Where to find the SQL text in v$ views?

    Hi All,
    Oracle 11.2.0.3 on RedHat.
    I am trying to find out SQL activity on my database for a very narrow time window. Please see the SQLs I did
    SQL> select distinct user_id, sql_id
      2  from v$active_session_history
      3  where sample_time between to_date('20120704012000','yyyymmddhh24miss') and
      4            to_date('20120704012200','yyyymmddhh24miss')
      5  and user_id = 111 ;
       USER_ID SQL_ID
           111
           111 gjg25k7stx9ba
           111 a8m049aj31b1y
           111 asjw7b7h99w4m
           111 fvffk1aqrb55n
           111 9gskv9b1u7mau
           111 03tsb9pp3h1uj
           111 dm0jppss5z0ay
           111 44n0svyuc000x
           111 16t1tpr7mdqnf
           111 bzpu510tng689
           111 dsqzhqdvzamys
    12 rows selected.
    SQL> select * from v$sqltext where sql_id='16t1tpr7mdqnf' order by piece ;
    no rows selected
    SQL> select * from table( dbms_xplan.display_awr('16t1tpr7mdqnf') ) ;
    no rows selectedI can see the text for all SQLs in v$sqltext, except 16t1tpr7mdqnf. User id 111 is the user used to run our batch processes.
    Where can I find the text for this SQL id 16t1tpr7mdqnf ?
    This SQL has run about 8 hours ago.
    Thanks in advance

    When you say, ASH captures active sessions, does that mean, it only captures "session" information, which may not include details about SQL ?Exactly, it's a snapshot of session level information for active sessions.
    So, session X can be executing sql statement abc123 and be captured by ASH which takes a snapshot of all active sessions every 1 second in V$ACTIVE_SESSION_HISTORY.
    1 in 10 of these active sessions is stored in the repository - DBA_HIST_ACTIVE_SESS_HISTORY (in practice, this 1 in 10 sample is literally as simple as store the active sessions from every 10th second).
    Independently of this, obviously you have the shared pool and V$SQL. If your statements are in here then great.
    Otherwise you have AWR which captures the top N sql from each interval.
    So, as mentioned, perfectly normal to have references to sql ids and sql plan hash values captured in ASH but not AWR.
    One interesting thing here is, sql_exec_id is blank. What does that say? It depends.
    It's likely to be one of two things:
    1. some sort of bug or limitation - there are certain operations and time limits were some of the ASH values get cleared out or don't get cleared out.
    2. occasionally I've seen the ASH information be misleading when it comes to certain recursive operations - one specific example I can think of related to the recursive merge of sql plan baseline metric tracking operations.

  • Using EXECUTE IMMEDIATE for DML

    What benefit is there to use EXECUTE IMMEDIATE for an UPDATE statement like the one below.
    EXECUTE IMMEDIATE 'UPDATE mytable SET bonus = v_bonus(i)
                       WHERE empid =:empid AND sal =:sal'
                              USING v_empid(n),v_sal(i);This UPDATE sql is not dynamically created. So is there any performance benefit associated with using
    EXECUTE IMMEDIATE for this UPDATE? Can't i just use a normal UPDATE without EXECUTE IMMEDIATE?

    Ran these same tests with SQL_Trace turned on, ran the trace files through tkprof and look at what it tells us:
    declare
    begin
    for i in 1 .. 100000 loop
    gso_prueba_a();
    end loop;
    end;
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.07       0.08          0          0          0           1
    Fetch        0      0.00       0.00          0          0          0           0
    total        2      0.07       0.08          0          0          0           1Now a slow one
    declare
    begin
    for i in 1 .. 100000 loop
    execute immediate 'call gso_prueba_b()';
    end loop;
    end;
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1     36.07      36.54          0          0          0           1
    Fetch        0      0.00       0.00          0          0          0           0
    total        2     36.07      36.54          0          0          0           1but with this slow one, we see LOTS of recursive SQL - the 'call gso_prueba_b' is getting parsed a gazillion times with the resulting CPU consumption
    SQL ID : 1uu09hhqdp1yz
    call gso_prueba_b()
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute  99989      2.42       2.72          0          0          0           0
    Fetch        0      0.00       0.00          0          0          0           0
    total    99990      2.42       2.72          0          0          0           0
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 91     (recursive depth: 1)
    SQL ID : dcstr36r0vz0d
    select procedure#,procedurename,properties,itypeobj#
    from
    procedureinfo$ where obj#=:1 order by procedurename desc, overload# desc
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        2      0.00       0.00          0          4          0           1
    total        4      0.00       0.00          0          4          0           1Lots, lots more like this last one but having different SQL ID
    By wrapping the procedure call in a dynamically created anonymous block, you are incurring LOTS of overhead.
    What is it that you are trying to simulate.
    What are you trying to do?

  • Can any one answer this?

    All,
    Can we have any limit for using nested loop in PL/SQL?
    Regards
    ND

    user8900449 wrote:
    The recurssion no doubt is elegant but the only problem arises when you are doing some sql or dml inside it.
    Because it will end up opening as many cursors as your recursion revolves around.That depends on the scope of the cursor - whether it remains open for the duration of the procedure's lifetime, or whether it is closed before recursion occurs.
    Simple (and ugly) example using implicit cursors (cursor is created and destroyed before the recursive call is made in the current active code unit), thus a single open cursor exist (per call) for the lifespan of the entire recursive call.
    SQL> create or replace procedure Nest( levelNo number ) is
      2          i       integer;
      3  begin
      4          if levelNo > 0 then
      5                  select levelNo-1 into i from dual;
      6                  Nest( i );
      7          end if;
      8  end;
      9  /
    Procedure created.
    SQL>
    SQL> exec Nest(1000000)
    PL/SQL procedure successfully completed.
    So be careful in recursion along with sql operation inside it.Agreed. But why would one want to use open SQL cursors in recursion? (i.e. each recursion creating a cursor with scope that spans the recursive call)
    There are nested loop joins (courtesy of the CBO), hierarchical query support and so on. Using PL to solve a SQL problem (like doing manual nested loops in PL) is always a problem - not just an issue with PL recursion.

  • OracleBulkCopy WritetoServer does Select * from TableName , fix it please

    In Odp.Net latest version , whenever OracleBulkCopy.WritetoServer is called. It internally calls "Select * from TableName " to validate the table schema.
    I did some debugging and found that this is called in function GetMetaData() in OracleBulkCopy class .
    Please fix this issue by appending where 1=0 in the select clause so that it does not do a full table scan for every bulk copy insert.
    The whole advantage of OracleBulkcopy performance improvement is lost because of this line.
    When the Destination Table has < 1 lakh records this is not a big issue, but it degrades very badly when the destination table name has million records .
    Please release a patch as soon as possible.

    yes 100% sure, we even captured the trace logs from the Oracle Db end and we saw that "Select * from Tablename" was executed. See the trace below.
    To elaborate on it, I am a .Net Consultant, i even went into the Odp.Net dll code and verified that GetMetaData function is called when WritetoServer is called on a new OracleBulkCopyInstance.
    trace below
    SQL ID: 46dym63c8qhxd
    Plan Hash: 0
    select *
    from
    TABLEX
    call count cpu elapsed disk query current rows
    Parse 1 0.01 0.01 0 60 0 0
    Execute 0 0.00 0.00 0 0 0 0
    Fetch 0 0.00 0.00 0 0 0 0
    total 1 0.01 0.01 0 60 0 0
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 94
    Elapsed times include waiting on following events:
    Event waited on Times Max. Wait Total Waited
    ---------------------------------------- Waited ---------- ------------
    SQL*Net message to client 1 0.00 0.00
    SQL*Net message from client 1 0.00 0.00
    SQL ID: 5s2vzq2q78n3w
    Plan Hash: 0
    LOCK TABLE "SCHEMAX"."TABLEX" IN ROW EXCLUSIVE MODE NOWAIT
    call count cpu elapsed disk query current rows
    Parse 1 0.00 0.00 0 0 0 0
    Execute 1 0.00 0.00 0 0 0 0
    Fetch 0 0.00 0.00 0 0 0 0
    total 2 0.00 0.00 0 0 0 0
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 94 (recursive depth: 1)
    SQL ID: dbxwyh9wxp32b
    Plan Hash: 0
    LOCK TABLE "SCHEMAX"."TABLEX" PARTITION ("P3") IN EXCLUSIVE MODE
    NOWAIT
    call count cpu elapsed disk query current rows
    Parse 1 0.00 0.00 0 0 0 0
    Execute 1 0.00 0.00 0 0 0 0
    Fetch 0 0.00 0.00 0 0 0 0
    total 2 0.00 0.00 0 0 0 0
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 94 (recursive depth: 1)
    SQL ID: 9y27jut66ajz5
    Plan Hash: 0
    INSERT /*+ SYS_DL_CURSOR */ INTO "SCHEMAX"."TABLEX" PARTITION ("P3")
    ("PARTITION_ID","GID","SEGMENT_ID","RID","STATUS",
    "VERIFIC","FILE_ID","RECORD_ID","SUB_REC_ID",
    "S_ID2","FILLER1","FILLER2","FILLER3","FILLER4","FILLER5",
    "FILLER6","FILLER7","FILLER8","FILLER9","FILLER10","FILLER11","FILLER12",
    "FILLER13","FILLER14","FILLER15","FILLER16","FILLER17","FILLER18",
    "FILLER19","FILLER20","FILLER21","FILLER22","FILLER23","FILLER24",
    "FILLER25","FILLER26","FILLER27","FILLER28","FILLER29","FILLER30",
    "ID_BODY","CODE","EXP_DATE","SUB_RECORD_3","OCCUR",
    "PARENT","SEGMENT","ID_VALUE","IS_ID")
    VALUES
    (NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
    NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
    NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
    NULL,NULL,NULL,NULL)
    Edited by: Y2KPRABU on Jul 16, 2012 11:38 PM

  • Remove repeating letters

    11gR2 DB
    We have a string token with all small leters (Sample - abcdaeebfghiejklc)
    Need to remove all the repeating letters in this tring. Output should be abcdefghijkl
    I know how to do it by splitting the string into multiple rows, then use listagg to make it a string.
    But can we do it use without using any kind of row generation. By regexp or something?

    And if your version supports recursive subquery factoring:
    SQL> select  *
      2    from  tbl
      3  /
    STR
    abcdaeebfghiejklc
    abcdaeebfghiejk
    SQL> Now:
    with r(
           str,
           new_str,
           l
          ) as (
                 select  str,
                         cast(substr(str,1,1) as varchar2(4000)) new_str,
                         1 l
                   from  tbl
                union all
                 select  str,
                         case instr(new_str,substr(str,l + 1,1))
                           when 0 then new_str || substr(str,l + 1,1)
                           else new_str
                         end new_str,
                         l + 1 l
                   from  r
      where l < length(str)
    select  str,
            new_str
      from  r
      where l = length(str)
    STR               NEW_STR
    abcdaeebfghiejk   abcdefghijk
    abcdaeebfghiejklc abcdefghijkl
    SQL> SY.

  • Suggestions from tkprof output

    Hi All,
    I need to tune the following sql query. I have given the tkprof output of the sql, can you please suggest ways to improvise the query?
    Trace file: hsctst09_ora_1671386_10046.trc
    Sort options: prsela  fchela  exeela
    count    = number of times OCI procedure was executed
    cpu      = cpu time in seconds executing
    elapsed  = elapsed time in seconds executing
    disk     = number of physical reads of buffers from disk
    query    = number of buffers gotten for consistent read
    current  = number of buffers gotten in current mode (usually for update)
    rows     = number of rows processed by the fetch or execute call
    error connecting to database using: rms12/rms12
    ORA-01017: invalid username/password; logon denied
    EXPLAIN PLAN option disabled.
    select distinct RPE.promo_event_display_id             Event_Number,
           RPE.description                                 Event_Description,
           RPE.start_date                                  Event_Start_Date,
           RPE.end_date                                    Event_End_Date,
           (CASE RPD.state  
                 WHEN 'pcd.active'                     THEN 'Active'
                 WHEN 'pcd.approved'                   THEN 'Approved'
                 WHEN 'pcd.cancelled'                  THEN 'Cancelled'
                 WHEN 'pcd.conflictCheckForApproved'   THEN 'Conflict Check'
                 WHEN 'pcd.submitted'                  THEN 'Submitted'
                 WHEN 'pcd.complete'                   THEN 'Complete'
                 WHEN 'pcd.substate.working.worksheet' THEN 'Worksheet'
                 ELSE 'Unknown'                      
           END)                                            Event_Status,
           RP.promo_display_id                             Promotion_ID,
           RP.description                                  Promotion_Description,
           RP.start_date                                   Promotion_Start_Date,
           RP.end_date                                     Promotion_End_Date,
           RPDT.dept                                       Valid_Section,
           RTH.threshold_display_id                        Threshold_Number,
           RTH.name                                        Threshold_Description,
           RPC.comp_display_id                             Component_ID,
           RPC.name                                        Component_Description,
           RPC.tsl_comp_level_desc                         Description_at_the_till,
           'Threshold'                                     Component_Type,
           RPC.tsl_ext_promo_id                            External_ID,
           decode(RPC.funding_percent,null,'No','Yes')     Funding_Indicator,
           (CASE RPD.apply_to_code
                 WHEN 0 THEN 'Regular Only'
                 WHEN 1 THEN 'Clearance Only'
                 WHEN 2 THEN 'Regular and Clearance'
                 ELSE NULL
           END)                                            Apply_to,
           RPD.start_date                                  Component_start_date,
           RPD.end_date                                    Component_End_Date,
           '="'||RPT.item||'"'                             Item,
           IM.item_desc                                    Item_Description,
           '="'||TRPCT.tpnd_id||'"'                        Pack,
           IM1.item_desc                                   Pack_Description,
           decode(TRPCT.primary_tpnd,1,'Yes','No')         Primary_Pack,
           RPC.funding_percent                             Corporate_Funding_Percent,
           DP.contribution_pct                             Supplier_Funding_Percent,
           RPCT.uptake_percent                             Uptake_Percent,
           RPT.tsl_uplift_perc                             Uplift_Percent,
           NULL                                            List_Type,
           NULL                                            Buy_Type,
           NULL                                            Buy_Value,
           (CASE RTI.threshold_type
                 WHEN 0 THEN 'Amount'
                 WHEN 1 THEN 'Quantity'
                 WHEN 2 THEN 'Weight'
                 ELSE NULL
           END)                                            Get_Type,
           RTI.threshold_amount                            Get_Value,
           (CASE RTI.change_type
                 WHEN 0 THEN 'Percent Off'
                 WHEN 1 THEN 'Amount Off'
                 WHEN 2 THEN 'Fixed Price'
                 WHEN 3 THEN 'No Change'
                 WHEN 4 THEN 'Exclude'
                 WHEN 5 THEN 'ClubCard Points'
                 WHEN 6 THEN 'Voucher'
                 WHEN 7 THEN 'Cheapest Free'
                 ELSE NULL
           END)                                            Change_Type,
           RTI.change_amount                               Change_Amount,
           RTI.tsl_voucher_number                          Voucher_Number,
           NULL                                            Get_Quantity,
           RZFR.selling_uom                                Selling_UOM,
           RPCT.tsl_coupon_number                          Coupon_Number,
           RPCT.tsl_coupon_desc                            Coupon_Description,
           RPT.zone_id                                     Zone,
           RPD.Ignore_Constraints                          Ignore_Constraints,
           RPT.tsl_feature_space_end_num                   Feature_Space
      from rpm_promo RP,
           rpm_promo_comp RPC,
           rpm_promo_comp_detail RPD,
           rpm_promo_event RPE,
           rpm_promo_dept RPDT,
           rpm_promo_comp_threshold RPT,
           rpm_threshold RTH,
           rpm_threshold_interval RTI,
           v_item_master IM,
           item_supplier SU,
           rpm_promo_comp_thresh_link RPCT,
           tsl_rpm_promo_comp_tpnd TRPCT,
           v_item_master IM1,
           rpm_zone_future_retail RZFR,
           ( select isu.supplier,
                    isu.item,
                    dh.deal_id,
                    dcp.promotion_id,
                    dcp.promo_comp_id,
                    dcp.contribution_pct
               from item_supplier isu inner join
                    deal_head dh on (isu.supplier = dh.supplier)
                    inner join deal_comp_prom dcp on (dcp.deal_id = dh.deal_id) ) dp
    where RP.promo_id = RPC.promo_id
       and RPD.promo_comp_id = RPC.promo_comp_id
       and RPE.promo_event_id = RP.promo_event_id
       and RP.promo_id = RPDT.promo_id
       and RPDT.dept = IM.dept
       and DP.promotion_id (+) = RP.promo_id
       and RPT.rpm_promo_comp_detail_id = RPD.rpm_promo_comp_detail_id
       and RPT.threshold_id = RTH.threshold_id
       and RPT.threshold_id = RTI.threshold_id
       and TRPCT.rpm_promo_comp_detail_id = RPD.rpm_promo_comp_detail_id
       and RPT.item = IM.item
       and IM.item = SU.item
       and RPD.promo_comp_id = RPCT.promo_comp_id
       and TRPCT.tpnb_id = RPT.item
       and TRPCT.tpnd_id = IM1.item
       and RZFR.item = IM.item
    UNION ALL
    -- Simple Query
    select distinct RPE.promo_event_display_id             Event_Number,
           RPE.description                                 Event_Description,
           RPE.start_date                                  Event_Start_Date,
           RPE.end_date                                    Event_End_Date,
           (CASE RPD.state  
                 WHEN 'pcd.active'                     THEN 'Active'
                 WHEN 'pcd.approved'                   THEN 'Approved'
                 WHEN 'pcd.cancelled'                  THEN 'Cancelled'
                 WHEN 'pcd.conflictCheckForApproved'   THEN 'Conflict Check'
                 WHEN 'pcd.submitted'                  THEN 'Submitted'
                 WHEN 'pcd.complete'                   THEN 'Complete'
                 WHEN 'pcd.substate.working.worksheet' THEN 'Worksheet'
                 ELSE 'Unknown'                      
           END)                                            Event_Status,
           RP.promo_display_id                             Promotion_ID,
           RP.description                                  Promotion_Description,
           RP.start_date                                   Promotion_Start_Date,
           RP.end_date                                     Promotion_End_Date,
           RPDT.dept                                       Valid_Section,
           NULL                                            Threshold_Number,
           NULL                                            Threshold_Description,
           RPC.comp_display_id                             Component_ID,
           RPC.name                                        Component_Description,
           RPC.tsl_comp_level_desc                         Description_at_the_till,
           'Simple'                                        Component_Type,
           RPC.tsl_ext_promo_id                            External_ID,
           decode(RPC.funding_percent,null,'No','Yes')     Funding_Indicator,
           (CASE RPD.apply_to_code
                 WHEN 0 THEN 'Regular Only'
                 WHEN 1 THEN 'Clearance Only'
                 WHEN 2 THEN 'Regular and Clearance'
                 ELSE NULL
           END)                                            Apply_to,
           RPD.start_date                                  Component_start_date,
           RPD.end_date                                    Component_End_Date,
           '="'||RPS.item||'"'                             Item,
           IM.item_desc                                    Item_Description,
           '="'||TRPCT.tpnd_id||'"'                        Pack,
           IM1.item_desc                                   Pack_Description,
           decode(TRPCT.primary_tpnd,1,'Yes','No')         Primary_Pack,
           RPC.funding_percent                             Corporate_Funding_Percent,
           DP.contribution_pct                             Supplier_Funding_Percent,
           RPS.tsl_simple_uptake_percent                   Uptake_Percent,
           RPS.tsl_uplift_perc                             Uplift_Percent,
           NULL                                            List_Type,
           NULL                                            Buy_Type,
           NULL                                            Buy_Value,
           NULL                                            Get_Type,
           NULL                                            Get_Value,
           (CASE RPS.change_type
                 WHEN 0 THEN 'Percent Off'
                 WHEN 1 THEN 'Amount Off'
                 WHEN 2 THEN 'Fixed Price'
                 WHEN 3 THEN 'No Change'
                 WHEN 4 THEN 'Exclude'
                 WHEN 5 THEN 'ClubCard Points'
                 WHEN 6 THEN 'Voucher'
                 WHEN 7 THEN 'Cheapest Free'
                 ELSE NULL
           END)                                            Change_Type,
           RPS.change_amount                               Change_Amount,
           RPS.tsl_voucher_number                          Voucher_Number,
           NULL                                            Get_Quantity,
           RZFR.selling_uom                                Selling_UOM,
           RPS.tsl_coupon_number                           Coupon_Number,
           RPS.tsl_coupon_desc                             Coupon_Description,
           RPS.zone_id                                     Zone,
           RPD.Ignore_Constraints                          Ignore_Constraints,
           RPS.tsl_feature_space_end_num                   Feature_Space
      from rpm_promo RP,
           rpm_promo_comp RPC,
           rpm_promo_comp_detail RPD,
           rpm_promo_event RPE,
           rpm_promo_dept RPDT,
           rpm_promo_comp_simple RPS,
           v_item_master IM,
           item_supplier SU,
           tsl_rpm_promo_comp_tpnd TRPCT,
           v_item_master IM1,
           rpm_zone_future_retail RZFR,
           ( select isu.supplier,
                    isu.item,
                    dh.deal_id,
                    dcp.promotion_id,
                    dcp.promo_comp_id,
                    dcp.contribution_pct
               from item_supplier isu inner join
                    deal_head dh on (isu.supplier = dh.supplier)
                    inner join deal_comp_prom dcp on (dcp.deal_id = dh.deal_id) ) dp
    where RP.promo_id = RPC.promo_id
       and RPD.promo_comp_id = RPC.promo_comp_id
       and RPE.promo_event_id = RP.promo_event_id
       and RP.promo_id = RPDT.promo_id
       and RPDT.dept = IM.dept
       and DP.promotion_id (+) = RP.promo_id
       and RPS.rpm_promo_comp_detail_id = RPD.rpm_promo_comp_detail_id
       and TRPCT.rpm_promo_comp_detail_id = RPD.rpm_promo_comp_detail_id
       and RPS.item = IM.item
       and IM.item = SU.item
       and RZFR.item = RPS.item
       and TRPCT.tpnb_id = RPS.item
       and TRPCT.tpnd_id = IM1.item
    UNION ALL
    -- Multi-Buy Query
    select distinct RPE.promo_event_display_id             Event_Number,
           RPE.description                                 Event_Description,
           RPE.start_date                                  Event_Start_Date,
           RPE.end_date                                    Event_End_Date,
           (CASE RPD.state  
                 WHEN 'pcd.active'                     THEN 'Active'
                 WHEN 'pcd.approved'                   THEN 'Approved'
                 WHEN 'pcd.cancelled'                  THEN 'Cancelled'
                 WHEN 'pcd.conflictCheckForApproved'   THEN 'Conflict Check'
                 WHEN 'pcd.submitted'                  THEN 'Submitted'
                 WHEN 'pcd.complete'                   THEN 'Complete'
                 WHEN 'pcd.substate.working.worksheet' THEN 'Worksheet'
                 ELSE 'Unknown'                      
           END)                                            Event_Status,
           RP.promo_display_id                             Promotion_ID,
           RP.description                                  Promotion_Description,
           RP.start_date                                   Promotion_Start_Date,
           RP.end_date                                     Promotion_End_Date,
           RPDT.dept                                       Valid_Section,
           NULL                                            Threshold_Number,
           NULL                                            Threshold_Description,
           RPC.comp_display_id                             Component_ID,
           RPC.name                                        Component_Description,
           RPC.tsl_comp_level_desc                         Description_at_the_till,
           'MultiBuy'                                      Component_Type,
           RPC.tsl_ext_promo_id                            External_ID,
           decode(RPC.funding_percent,null,'No','Yes')     Funding_Indicator,
           (CASE RPD.apply_to_code
                 WHEN 0 THEN 'Regular Only'
                 WHEN 1 THEN 'Clearance Only'
                 WHEN 2 THEN 'Regular and Clearance'
                 ELSE NULL
           END)                                            Apply_to,
           RPD.start_date                                  Component_start_date,
           RPD.end_date                                    Component_End_Date,
           '="'||RPG.item||'"'                             Item,
           IM.item_desc                                    Item_Description,
           '="'||TRPCT.tpnd_id||'"'                        Pack,
           IM1.item_desc                                   Pack_Description,
           decode(TRPCT.primary_tpnd,1,'Yes','No')         Primary_Pack,
           RPC.funding_percent                             Corporate_Funding_Percent,
           DP.contribution_pct                             Supplier_Funding_Percent,
           NULL                                            Uptake_Percent,
           TRPM.uplift_perc                                Uplift_Percent,
           decode(TBD.list_type,0,'Buy List',1,'Get List') List_Type,
           TBD.buy_item_type                               Buy_Type,
           TBD.buy_item_value                              Buy_Value,
           NULL                                            Get_Type,
           NULL                                            Get_Value,
           (CASE TBD.change_type
                 WHEN 0 THEN 'Percent Off'
                 WHEN 1 THEN 'Amount Off'
                 WHEN 2 THEN 'Fixed Price'
                 WHEN 3 THEN 'No Change'
                 WHEN 4 THEN 'Exclude'
                 WHEN 5 THEN 'ClubCard Points'
                 WHEN 6 THEN 'Voucher'
                 WHEN 7 THEN 'Cheapest Free'
                 ELSE NULL
           END)                                            Change_Type,
           TBD.change_amount                               Change_Amount,
           TBD.voucher_number                              Voucher_Number,
           TBD.get_quantity                                Get_Quantity,
           RZPR.selling_uom                                Selling_UOM,               
           TB.tsl_coupon_number                            Coupon_Number,
           TB.tsl_coupon_desc                              Coupon_Description,
           TBZ.zone_id                                     Zone,
           RPD.Ignore_Constraints                          Ignore_Constraints,
           NULL                                            Feature_Space
      from rpm_promo RP,
           rpm_promo_comp RPC,
           rpm_promo_comp_detail RPD,
           rpm_promo_event RPE,
           rpm_promo_dept RPDT,
           tsl_rpm_promo_comp_m_b TB,
           tsl_rpm_promo_comp_m_b_dtl TBD,
           tsl_rpm_promo_multi_buy_zone TBZ,
           tsl_rpm_promo_get_item RPG,
           v_item_master IM,
           item_supplier SU,
           tsl_rpm_promo_comp_tpnd TRPCT,
           v_item_master IM1,
           rpm_zone_future_retail RZPR,
           tsl_rpm_promo_mb_attr TRPM,
           ( select isu.supplier,
                    isu.item,
                    dh.deal_id,
                    dcp.promotion_id,
                    dcp.promo_comp_id,
                    dcp.contribution_pct
               from item_supplier isu inner join
                    deal_head dh on (isu.supplier = dh.supplier)
                    inner join deal_comp_prom dcp on (dcp.deal_id = dh.deal_id) ) dp
    where RP.promo_id = RPC.promo_id
       and RPD.promo_comp_id = RPC.promo_comp_id
       and RPE.promo_event_id = RP.promo_event_id
       and RP.promo_id = RPDT.promo_id
       and RPDT.dept = IM.dept
       and DP.promotion_id (+) = RP.promo_id
       and RPD.rpm_promo_comp_detail_id = TB.rpm_promo_comp_detail_id
       and TB.rpm_promo_comp_detail_id = TBD.rpm_promo_comp_detail_id
       and TBD.rpm_promo_comp_detail_id = TBZ.rpm_promo_comp_detail_id
       and RPG.item = IM.item
       and IM.item = SU.item
       and TRPM.item = RPG.item
       and TRPM.rpm_promo_comp_detail_id = RPD.rpm_promo_comp_detail_id
       and TRPM.zone_id = TBZ.zone_id
       and RZPR.item = RPG.item
       and TRPCT.tpnb_id = RPG.item
       and TRPCT.tpnd_id = IM1.item

    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      4.16       4.48          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        5     53.01     276.29      91547    1615664          9          48
    total        7     57.17     280.78      91547    1615664          9          48
    Misses in library cache during parse: 1
    Optimizer mode: CHOOSE
    Parsing user id: 191
    Rows     Row Source Operation
         48  UNION-ALL  (cr=17287 pr=3663 pw=1876 time=2033194 us)
         13   SORT UNIQUE (cr=11286 pr=1052 pw=0 time=2033182 us)
        364    NESTED LOOPS OUTER (cr=11286 pr=1052 pw=0 time=1861854 us)
        364     NESTED LOOPS  (cr=10922 pr=1051 pw=0 time=1857466 us)
         75      NESTED LOOPS  (cr=10770 pr=1041 pw=0 time=1855506 us)
         15       NESTED LOOPS  (cr=10723 pr=1029 pw=0 time=1857844 us)
         15        NESTED LOOPS  (cr=10691 pr=1021 pw=0 time=1857525 us)
         15         NESTED LOOPS  (cr=10689 pr=1021 pw=0 time=1857391 us)
         15          NESTED LOOPS  (cr=10657 pr=1017 pw=0 time=1856760 us)
         15           NESTED LOOPS  (cr=10655 pr=1017 pw=0 time=1856639 us)
         15            NESTED LOOPS  (cr=10623 pr=1006 pw=0 time=1855895 us)
         15             NESTED LOOPS  (cr=10606 pr=1003 pw=0 time=1846410 us)
       1208              NESTED LOOPS  (cr=8188 pr=989 pw=0 time=1846542 us)
       1208               NESTED LOOPS  (cr=5770 pr=978 pw=0 time=1834421 us)
       1208                NESTED LOOPS  (cr=4560 pr=971 pw=0 time=1821047 us)
       1208                 HASH JOIN  (cr=3350 pr=970 pw=0 time=1801632 us)
       1367                  HASH JOIN  (cr=2533 pr=157 pw=0 time=25928 us)
         96                   TABLE ACCESS FULL RPM_PROMO_COMP_THRESH_LINK (cr=9 pr=8 pw=0 time=435 us)
       1371                   HASH JOIN  (cr=2524 pr=149 pw=0 time=24005 us)
       1371                    TABLE ACCESS FULL RPM_PROMO_COMP_THRESHOLD (cr=47 pr=0 pw=0 time=33 us)
    190227                    TABLE ACCESS FULL RPM_PROMO_COMP_DETAIL (cr=2477 pr=149 pw=0 time=87 us)
    132392                  TABLE ACCESS FULL TSL_RPM_PROMO_COMP_TPND (cr=817 pr=813 pw=0 time=337 us)
       1208                 TABLE ACCESS BY INDEX ROWID RPM_THRESHOLD_INTERVAL (cr=1210 pr=1 pw=0 time=16962 us)
       1208                  INDEX RANGE SCAN RPM_THRESHOLD_INTERVAL_I1 (cr=2 pr=1 pw=0 time=4680 us)(object id 459922)
       1208                TABLE ACCESS BY INDEX ROWID RPM_THRESHOLD (cr=1210 pr=7 pw=0 time=8397 us)
       1208                 INDEX UNIQUE SCAN PK_RPM_THRESHOLD (cr=2 pr=1 pw=0 time=3405 us)(object id 459954)
       1208               TABLE ACCESS BY INDEX ROWID RPM_PROMO_COMP (cr=2418 pr=11 pw=0 time=37425 us)
       1208                INDEX UNIQUE SCAN PK_RPM_PROMO_COMP (cr=1210 pr=4 pw=0 time=4700 us)(object id 459902)
         15              TABLE ACCESS BY INDEX ROWID RPM_PROMO (cr=2418 pr=14 pw=0 time=69147 us)
       1208               INDEX UNIQUE SCAN PK_RPM_PROMO (cr=1210 pr=4 pw=0 time=4755 us)(object id 459849)
         15             TABLE ACCESS BY INDEX ROWID RPM_PROMO_EVENT (cr=17 pr=3 pw=0 time=9808 us)
         15              INDEX UNIQUE SCAN PK_RPM_PROMO_EVENT (cr=2 pr=0 pw=0 time=55 us)(object id 459871)
         15            TABLE ACCESS BY INDEX ROWID ITEM_MASTER (cr=32 pr=11 pw=0 time=638 us)
         15             INDEX UNIQUE SCAN PK_ITEM_MASTER (cr=17 pr=7 pw=0 time=398 us)(object id 460014)
         15           INDEX UNIQUE SCAN PK_DEPS (cr=2 pr=0 pw=0 time=55 us)(object id 460063)
         15          TABLE ACCESS BY INDEX ROWID ITEM_MASTER (cr=32 pr=4 pw=0 time=284 us)
         15           INDEX UNIQUE SCAN PK_ITEM_MASTER (cr=17 pr=3 pw=0 time=179 us)(object id 460014)
         15         INDEX UNIQUE SCAN PK_DEPS (cr=2 pr=0 pw=0 time=47 us)(object id 460063)
         15        INDEX UNIQUE SCAN PK_RPM_PROMO_DEPT (cr=32 pr=8 pw=0 time=423 us)(object id 461683)
         75       TABLE ACCESS BY INDEX ROWID RPM_ZONE_FUTURE_RETAIL (cr=47 pr=12 pw=0 time=846 us)
         75        INDEX RANGE SCAN RPM_ZONE_FUTURE_RETAIL_I1 (cr=32 pr=12 pw=0 time=536 us)(object id 459917)
        364      INDEX RANGE SCAN PK_ITEM_SUPPLIER (cr=152 pr=10 pw=0 time=915 us)(object id 461283)
          0     VIEW PUSHED PREDICATE  (cr=364 pr=1 pw=0 time=4468 us)
          0      NESTED LOOPS  (cr=364 pr=1 pw=0 time=4023 us)
          0       NESTED LOOPS  (cr=364 pr=1 pw=0 time=3596 us)
          0        TABLE ACCESS BY INDEX ROWID DEAL_COMP_PROM (cr=364 pr=1 pw=0 time=2839 us)
          0         INDEX SKIP SCAN PK_DEAL_COMP_PROM (cr=364 pr=1 pw=0 time=2252 us)(object id 460586)
          0        TABLE ACCESS BY INDEX ROWID DEAL_HEAD (cr=0 pr=0 pw=0 time=0 us)
          0         INDEX UNIQUE SCAN PK_DEAL_HEAD (cr=0 pr=0 pw=0 time=0 us)(object id 460002)
          0       INDEX RANGE SCAN ITEM_SUPPLIER_I1 (cr=0 pr=0 pw=0 time=0 us)(object id 461281)
         35   SORT UNIQUE (cr=6001 pr=2611 pw=1876 time=1787923 us)
        483    TABLE ACCESS BY INDEX ROWID RPM_ZONE_FUTURE_RETAIL (cr=6001 pr=2611 pw=1876 time=1781697 us)
        579     NESTED LOOPS  (cr=5969 pr=2609 pw=1876 time=205507332 us)
         95      NESTED LOOPS  (cr=5777 pr=2600 pw=1876 time=1777879 us)
         41       NESTED LOOPS  (cr=5693 pr=2592 pw=1876 time=1778919 us)
         41        HASH JOIN  (cr=5609 pr=2573 pw=1876 time=1778377 us)
        276         TABLE ACCESS FULL DEPS (cr=5 pr=0 pw=0 time=36 us)
         41         NESTED LOOPS  (cr=5604 pr=2573 pw=1876 time=1776404 us)
         41          HASH JOIN  (cr=5520 pr=2567 pw=1876 time=1776506 us)
         41           NESTED LOOPS  (cr=5515 pr=2567 pw=1876 time=1753418 us)
         41            HASH JOIN  (cr=5431 pr=2555 pw=1876 time=1752249 us)
    132392             TABLE ACCESS FULL TSL_RPM_PROMO_COMP_TPND (cr=817 pr=0 pw=0 time=44 us)
         57             HASH JOIN  (cr=4614 pr=1820 pw=1099 time=1200744 us)
    129467              TABLE ACCESS FULL RPM_PROMO_COMP_SIMPLE (cr=1693 pr=164 pw=0 time=186 us)
      45903              HASH JOIN  (cr=2921 pr=557 pw=0 time=81106 us)
        236               HASH JOIN  (cr=444 pr=28 pw=0 time=37993 us)
        373                NESTED LOOPS OUTER (cr=413 pr=23 pw=0 time=10806 us)
        373                 HASH JOIN  (cr=40 pr=23 pw=0 time=6301 us)
        277                  TABLE ACCESS FULL RPM_PROMO_EVENT (cr=6 pr=1 pw=0 time=79 us)
        373                  TABLE ACCESS FULL RPM_PROMO (cr=34 pr=22 pw=0 time=4177 us)
          0                 VIEW PUSHED PREDICATE  (cr=373 pr=0 pw=0 time=4164 us)
          0                  NESTED LOOPS  (cr=373 pr=0 pw=0 time=3634 us)
          0                   NESTED LOOPS  (cr=373 pr=0 pw=0 time=3221 us)
          0                    TABLE ACCESS BY INDEX ROWID DEAL_COMP_PROM (cr=373 pr=0 pw=0 time=2799 us)
          0                     INDEX SKIP SCAN PK_DEAL_COMP_PROM (cr=373 pr=0 pw=0 time=2244 us)(object id 460586)
          0                    TABLE ACCESS BY INDEX ROWID DEAL_HEAD (cr=0 pr=0 pw=0 time=0 us)
          0                     INDEX UNIQUE SCAN PK_DEAL_HEAD (cr=0 pr=0 pw=0 time=0 us)(object id 460002)
          0                   INDEX RANGE SCAN ITEM_SUPPLIER_I1 (cr=0 pr=0 pw=0 time=0 us)(object id 461281)
       1452                TABLE ACCESS FULL RPM_PROMO_COMP (cr=31 pr=5 pw=0 time=8984 us)
    190227               TABLE ACCESS FULL RPM_PROMO_COMP_DETAIL (cr=2477 pr=529 pw=0 time=1525455 us)
         41            TABLE ACCESS BY INDEX ROWID ITEM_MASTER (cr=84 pr=12 pw=0 time=21811 us)
         41             INDEX UNIQUE SCAN PK_ITEM_MASTER (cr=43 pr=2 pw=0 time=500 us)(object id 460014)
        276           TABLE ACCESS FULL DEPS (cr=5 pr=0 pw=0 time=39 us)
         41          TABLE ACCESS BY INDEX ROWID ITEM_MASTER (cr=84 pr=6 pw=0 time=750 us)
         41           INDEX UNIQUE SCAN PK_ITEM_MASTER (cr=43 pr=2 pw=0 time=360 us)(object id 460014)
         41        INDEX UNIQUE SCAN PK_RPM_PROMO_DEPT (cr=84 pr=19 pw=0 time=1025 us)(object id 461683)
         95       INDEX RANGE SCAN PK_ITEM_SUPPLIER (cr=84 pr=8 pw=0 time=717 us)(object id 461283)
        483      INDEX RANGE SCAN RPM_ZONE_FUTURE_RETAIL_I1 (cr=192 pr=9 pw=0 time=1661 us)(object id 459917)
          0   SORT UNIQUE (cr=0 pr=0 pw=0 time=34 us)
          0    HASH JOIN  (cr=0 pr=0 pw=0 time=8 us)
        276     TABLE ACCESS FULL DEPS (cr=5 pr=0 pw=0 time=175 us)
          0     HASH JOIN  (cr=0 pr=0 pw=0 time=4 us)
    110442      TABLE ACCESS FULL RPM_ZONE_FUTURE_RETAIL (cr=990 pr=101 pw=0 time=108 us)
          0      HASH JOIN  (cr=0 pr=0 pw=0 time=11 us)
    126852       TABLE ACCESS FULL ITEM_MASTER (cr=5389 pr=5268 pw=0 time=1522285 us)
    8076819       HASH JOIN  (cr=1591993 pr=82513 pw=128338 time=97917982 us)
    1611192        HASH JOIN  (cr=1591176 pr=80224 pw=78099 time=57413444 us)
    1611192         HASH JOIN  (cr=1590457 pr=28794 pw=27384 time=20659952 us)
    793008          HASH JOIN  (cr=1589595 pr=1843 pw=1267 time=12259546 us)
        276           TABLE ACCESS FULL DEPS (cr=5 pr=0 pw=0 time=383 us)
    793008           NESTED LOOPS  (cr=1589590 pr=1843 pw=1267 time=10672032 us)
    793008            HASH JOIN  (cr=3572 pr=1815 pw=1267 time=2741847 us)
      43362             HASH JOIN  (cr=3426 pr=493 pw=0 time=379252 us)
        985              TABLE ACCESS FULL TSL_RPM_PROMO_MULTI_BUY_ZONE (cr=5 pr=4 pw=0 time=207 us)
      43362              HASH JOIN  (cr=3421 pr=489 pw=0 time=288896 us)
        388               HASH JOIN  (cr=2934 pr=5 pw=0 time=22834 us)
       1624                TABLE ACCESS FULL TSL_RPM_PROMO_COMP_M_B_DTL (cr=9 pr=0 pw=0 time=34 us)
        194                HASH JOIN  (cr=2925 pr=5 pw=0 time=30088 us)
        795                 TABLE ACCESS FULL TSL_RPM_PROMO_COMP_M_B (cr=4 pr=2 pw=0 time=179 us)
      45903                 HASH JOIN  (cr=2921 pr=3 pw=0 time=109197 us)
        236                  HASH JOIN  (cr=444 pr=3 pw=0 time=16642 us)
        373                   NESTED LOOPS OUTER (cr=413 pr=0 pw=0 time=7419 us)
        373                    HASH JOIN  (cr=40 pr=0 pw=0 time=2166 us)
        277                     TABLE ACCESS FULL RPM_PROMO_EVENT (cr=6 pr=0 pw=0 time=48 us)
        373                     TABLE ACCESS FULL RPM_PROMO (cr=34 pr=0 pw=0 time=414 us)
          0                    VIEW PUSHED PREDICATE  (cr=373 pr=0 pw=0 time=4519 us)
          0                     NESTED LOOPS  (cr=373 pr=0 pw=0 time=4033 us)
          0                      NESTED LOOPS  (cr=373 pr=0 pw=0 time=3611 us)
          0                       TABLE ACCESS BY INDEX ROWID DEAL_COMP_PROM (cr=373 pr=0 pw=0 time=3166 us)
          0                        INDEX SKIP SCAN PK_DEAL_COMP_PROM (cr=373 pr=0 pw=0 time=2559 us)(object id 460586)
          0                       TABLE ACCESS BY INDEX ROWID DEAL_HEAD (cr=0 pr=0 pw=0 time=0 us)
          0                        INDEX UNIQUE SCAN PK_DEAL_HEAD (cr=0 pr=0 pw=0 time=0 us)(object id 460002)
          0                      INDEX RANGE SCAN ITEM_SUPPLIER_I1 (cr=0 pr=0 pw=0 time=0 us)(object id 461281)
       1452                   TABLE ACCESS FULL RPM_PROMO_COMP (cr=31 pr=3 pw=0 time=38 us)
    190227                  TABLE ACCESS FULL RPM_PROMO_COMP_DETAIL (cr=2477 pr=0 pw=0 time=36 us)
      69561               TABLE ACCESS FULL TSL_RPM_PROMO_MB_ATTR (cr=487 pr=484 pw=0 time=361 us)
      25271             TABLE ACCESS FULL TSL_RPM_PROMO_GET_ITEM (cr=146 pr=55 pw=0 time=53 us)
    793008            TABLE ACCESS BY INDEX ROWID ITEM_MASTER (cr=1586018 pr=28 pw=0 time=7006432 us)
    793008             INDEX UNIQUE SCAN PK_ITEM_MASTER (cr=793010 pr=19 pw=0 time=3817845 us)(object id 460014)
    211165          INDEX FAST FULL SCAN PK_ITEM_SUPPLIER (cr=862 pr=834 pw=0 time=341 us)(object id 461283)
    378625         TABLE ACCESS FULL RPM_PROMO_DEPT (cr=719 pr=715 pw=0 time=333 us)
    132392        TABLE ACCESS FULL TSL_RPM_PROMO_COMP_TPND (cr=817 pr=0 pw=0 time=80 us)
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      SQL*Net message to client                       5        0.00          0.00
      db file sequential read                       627        0.51          1.69
      db file scattered read                        699        0.08          0.68
      SQL*Net more data to client                     1        0.00          0.00
      SQL*Net message from client                     4       50.64        149.95
      direct path write temp                      56227        0.32        219.45
      direct path read temp                       11746        0.01          0.69
      control file sequential read                    7        0.00          0.00
      SQL*Net break/reset to client                   2        0.00          0.00
    SQL ID:
    Plan Hash: 1248216388
    SELECT NAME NAME_COL_PLUS_SHOW_PARAM,DECODE(TYPE,1,'boolean',2,'string',3,
      'integer',4,'file',5,'number',        6,'big integer', 'unknown') TYPE,
      DISPLAY_VALUE VALUE_COL_PLUS_SHOW_PARAM
    FROM
    V$PARAMETER WHERE UPPER(NAME) LIKE UPPER('%USER_DUMP_DEST%') ORDER BY
      NAME_COL_PLUS_SHOW_PARAM,ROWNUM
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        2      0.01       0.01          0          0          0           1
    total        4      0.01       0.02          0          0          0           1
    Misses in library cache during parse: 1
    Optimizer mode: CHOOSE
    Parsing user id: 191
    Rows     Row Source Operation
          1  SORT ORDER BY (cr=0 pr=0 pw=0 time=15029 us)
          1   COUNT  (cr=0 pr=0 pw=0 time=15015 us)
          1    MERGE JOIN  (cr=0 pr=0 pw=0 time=15004 us)
       1495     FIXED TABLE FULL X$KSPPCV (cr=0 pr=0 pw=0 time=3021 us)
          1     FILTER  (cr=0 pr=0 pw=0 time=10994 us)
          1      SORT JOIN (cr=0 pr=0 pw=0 time=9469 us)
          1       FIXED TABLE FULL X$KSPPI (cr=0 pr=0 pw=0 time=7735 us)
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      SQL*Net message to client                       2        0.00          0.00
      SQL*Net message from client                     2     2763.24       2763.24
    SQL ID:
    Plan Hash: 643305917
    SELECT 'Y'
    FROM
    SEC_USER_GROUP SUG WHERE SUG.USER_ID = SYS_CONTEXT('USERENV', 'SESSION_USER')
       AND EXISTS(SELECT 'x' FROM FILTER_GROUP_MERCH FGM WHERE FGM.SEC_GROUP_ID =
      SUG.GROUP_ID AND ROWNUM = 1) AND ROWNUM = 1
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.01       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        1      0.00       0.01          1          3          0           0
    total        3      0.01       0.02          1          3          0           0
    Misses in library cache during parse: 1
    Optimizer mode: CHOOSE
    Parsing user id: 191     (recursive depth: 2)
    Rows     Row Source Operation
          0  COUNT STOPKEY (cr=3 pr=1 pw=0 time=12073 us)
          0   INDEX FULL SCAN PK_SEC_USER_GROUP (cr=3 pr=1 pw=0 time=12070 us)(object id 460226)
          0    COUNT STOPKEY (cr=2 pr=1 pw=0 time=12026 us)
          0     INDEX RANGE SCAN UK_FILTER_GROUP_MERCH (cr=2 pr=1 pw=0 time=12023 us)(object id 461052)
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      db file sequential read                         1        0.01          0.01
    SQL ID:
    Plan Hash: 643277548
    SELECT 'Y'
    FROM
    SEC_USER_GROUP SUG WHERE SUG.USER_ID = SYS_CONTEXT('USERENV', 'SESSION_USER')
       AND (EXISTS(SELECT 'x' FROM FILTER_GROUP_ORG FGO WHERE FGO.SEC_GROUP_ID =
      SUG.GROUP_ID AND ROWNUM = 1) OR EXISTS(SELECT 'x' FROM SEC_GROUP_LOC_MATRIX
      SGLM WHERE SGLM.GROUP_ID = SUG.GROUP_ID AND ROWNUM = 1)) AND ROWNUM = 1
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.01       0.01          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        1      0.02       0.00          2          3          0           0
    total        3      0.03       0.02          2          3          0           0
    Misses in library cache during parse: 1
    Optimizer mode: CHOOSE
    Parsing user id: 191     (recursive depth: 2)
    Rows     Row Source Operation
          0  COUNT STOPKEY (cr=3 pr=2 pw=0 time=8617 us)
          0   FILTER  (cr=3 pr=2 pw=0 time=8614 us)
          1    INDEX FULL SCAN PK_SEC_USER_GROUP (cr=1 pr=0 pw=0 time=39 us)(object id 460226)
          0    COUNT STOPKEY (cr=1 pr=1 pw=0 time=5403 us)
          0     INDEX RANGE SCAN PK_FILTER_GROUP_ORG (cr=1 pr=1 pw=0 time=5400 us)(object id 461061)
          0    COUNT STOPKEY (cr=1 pr=1 pw=0 time=3127 us)
          0     INDEX SKIP SCAN UK_SEC_GROUP_LOC_MATRIX (cr=1 pr=1 pw=0 time=3125 us)(object id 460888)
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      db file sequential read                         2        0.00          0.00
    SQL ID:
    Plan Hash: 4011473558
    SELECT NAME NAME_COL_PLUS_SHOW_PARAM,DECODE(TYPE,1,'boolean',2,'string',3,
      'integer',4,'file',5,'number',        6,'big integer', 'unknown') TYPE,
      DISPLAY_VALUE VALUE_COL_PLUS_SHOW_PARAM
    FROM
    V$PARAMETER WHERE UPPER(NAME) LIKE UPPER('%USER_DUMP_DEST%') ORDER BY
      NAME_COL_PLUS_SHOW_PARAM,ROWNUM
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        2      0.01       0.01          0          0          0           1
    total        4      0.01       0.01          0          0          0           1
    Misses in library cache during parse: 0
    Optimizer mode: CHOOSE
    Parsing user id: 191
    Rows     Row Source Operation
          1  SORT ORDER BY (cr=0 pr=0 pw=0 time=15250 us)
          1   COUNT  (cr=0 pr=0 pw=0 time=15226 us)
          1    MERGE JOIN  (cr=0 pr=0 pw=0 time=15207 us)
       1495     FIXED TABLE FULL X$KSPPCV (cr=0 pr=0 pw=0 time=3166 us)
          1     FILTER  (cr=0 pr=0 pw=0 time=11059 us)
          1      SORT JOIN (cr=0 pr=0 pw=0 time=9512 us)
          1       FIXED TABLE FULL X$KSPPI (cr=0 pr=0 pw=0 time=7741 us)
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      SQL*Net message to client                       2        0.00          0.00
      SQL*Net message from client                     2     3143.23       3143.23
    SQL ID:
    Plan Hash: 643140929
    SELECT 'Y'
    FROM
    SEC_USER_GROUP SUG WHERE SUG.USER_ID = SYS_CONTEXT('USERENV', 'SESSION_USER')
       AND ROWNUM = 1
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        1      0.00       0.00          1          1          0           1
    total        3      0.00       0.01          1          1          0           1
    Misses in library cache during parse: 1
    Optimizer mode: CHOOSE
    Parsing user id: 191     (recursive depth: 2)
    Rows     Row Source Operation
          1  COUNT STOPKEY (cr=1 pr=1 pw=0 time=6617 us)
          1   INDEX RANGE SCAN SEC_USER_GROUP_I1 (cr=1 pr=1 pw=0 time=6614 us)(object id 460225)
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      db file sequential read                         1        0.00          0.00
    SQL ID:
    Plan Hash: 642786159
    SELECT DATA_LEVEL_SECURITY_IND, DIFF_GROUP_ORG_LEVEL_CODE,
      LOC_LIST_ORG_LEVEL_CODE, LOC_TRAIT_ORG_LEVEL_CODE, SEASON_ORG_LEVEL_CODE,
      SKULIST_ORG_LEVEL_CODE, TICKET_TYPE_ORG_LEVEL_CODE, UDA_ORG_LEVEL_CODE,
      DIFF_GROUP_MERCH_LEVEL_CODE, SEASON_MERCH_LEVEL_CODE,
      TICKET_TYPE_MERCH_LEVEL_CODE, UDA_MERCH_LEVEL_CODE, TSL_LOC_SEC_IND
    FROM
    SYSTEM_OPTIONS
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.01       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        1      0.00       0.00          1          4          0           1
    total        3      0.01       0.01          1          4          0           1
    Misses in library cache during parse: 1
    Optimizer mode: CHOOSE
    Parsing user id: 191     (recursive depth: 2)
    Rows     Row Source Operation
          1  TABLE ACCESS FULL SYSTEM_OPTIONS (cr=4 pr=1 pw=0 time=6518 us)
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      db file sequential read                         1        0.00          0.00
    SQL ID:
    Plan Hash: 643306006
    begin :con := FILTER_POLICY_SQL.V_ITEM_MASTER_S(:sn, :on); end;
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           1
    Fetch        0      0.00       0.00          0          0          0           0
    total        2      0.00       0.00          0          0          0           1
    Misses in library cache during parse: 0
    Optimizer mode: CHOOSE
    Parsing user id: 191     (recursive depth: 1)
    SQL ID:
    Plan Hash: 647750573
    begin :con := FILTER_POLICY_SQL.V_ITEM_MASTER_S(:sn, :on); end;
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           1
    Fetch        0      0.00       0.00          0          0          0           0
    total        2      0.00       0.00          0          0          0           1
    Misses in library cache during parse: 0
    Optimizer mode: CHOOSE
    Parsing user id: 191     (recursive depth: 1)
    OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        3      4.16       4.49          0          0          0           0
    Execute      3      0.00       0.00          0          0          0           0
    Fetch        9     53.03     276.32      91547    1615664          9          50
    total       15     57.19     280.82      91547    1615664          9          50
    Misses in library cache during parse: 2
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      SQL*Net message to client                      10        0.00          0.00
      SQL*Net message from client                     9     3143.23       6091.69
      SQL*Net more data from client                   8        0.00          0.00
      db file sequential read                       627        0.51          1.69
      db file scattered read                        699        0.08          0.68
      SQL*Net more data to client                     1        0.00          0.00
      direct path write temp                      56227        0.32        219.45
      direct path read temp                       11746        0.01          0.69
      control file sequential read                    7        0.00          0.00
      SQL*Net break/reset to client                   2        0.00          0.00
    OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
    call     count       cpu    elapsed       disk      query    current        rows
    Parse       93      0.08       0.07          0          0          0           0
    Execute    579      0.12       0.14          0          0          0           2
    Fetch      930      0.06       0.51         63       2154          0        3254
    total     1602      0.26       0.73         63       2154          0        3256
    Misses in library cache during parse: 25
    Misses in library cache during execute: 21
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      db file sequential read                        63        0.14          0.47
        9  user  SQL statements in session.
      573  internal SQL statements in session.
      582  SQL statements in session.
        0  statements EXPLAINed in this session.
    Trace file: hsctst09_ora_1671386_10046.trc
    Trace file compatibility: 11.1.0.7
    Sort options: prsela  fchela  exeela
           1  session in tracefile.
           9  user  SQL statements in trace file.
         573  internal SQL statements in trace file.
         582  SQL statements in trace file.
          36  unique SQL statements in trace file.
       81769  lines in trace file.
    17819535  elapsed seconds in trace file.Thanks in advance.

  • Why checkpoint increase SCN?

    the database is not used now,and I uses command
    "alter system checkpoint" repeatly,and every time
    checkpoint,the SCN will increase,but there is nobody
    using the database,and there is no transaction to
    commit,why will SCN increase? From oracle doc,every
    time commit,the SCN will increase,under what
    situation will SCN alse increase?

    under what situation will SCN alse increaseThe recovery process uses SCN to identify a particular state of the database.
    Oracle sometimes says SCN stands for System Commit Number (e.g. error message for ORA-8209) but this is misleading because it can also be incremented by other things. These things are not well documented, but they seem to be related to recursive data dictionary SQL (which makes sense). One such is block cleanout. Another is checkpointing, as you've noticed. I believe activity by stuff like AQ, DBMS_JOB, etc will increment the SCN.
    There is an aside in Metalink note #28929.1 which states rather tantalizingly:
    In some situations, the SCN increment during startup may permit the database to open.
    Does this mean STARTUP also increments the SCN? Something for me to test when I get home this evening.
    Does anybody out there have a definitive list?
    Cheers, APC

  • ORA-00604: error occurred at recursive SQL level 1 ORA-01882: timezone

    Hi
    I'm trying to config my base_domain for SOA11g but i'm getting the following error when connecting to my Oracle XE DB to configure SOA,
    please help thanks
    Software installed
    OS: Windows 7 64bit
    DB: Oracle XE 10g
    Oracle SOA 11.1.1.4.0
    Oracle RCU 11.1.1.4.0
    Oracle wls1034_generic
    Error Detials
    Component Schema=SOA Infrastructure
    Driver=oracle.jdbc.xa.client.OracleXADataSource
    URL=jdbc:oracle:thin:@127.0.0.1:1521/XE
    User=DEV_SOAINFRA
    Password=********
    SQL Test=select 1 from schema_version_registry where owner=(select user from dual) and mr_type='SOAINFRA' and version='11.1.1.4.0'
    ORA-00604: error occurred at recursive SQL level 1
    ORA-01882: timezone region  not found
    CFGFWK-60850:  Test Failed!
    Component Schema=User Messaging Service
    Driver=oracle.jdbc.OracleDriver
    URL=jdbc:oracle:thin:@127.0.0.1:1521/XE
    User=DEV_ORASDPM
    Password=********
    SQL Test=select 1 from schema_version_registry where owner=(select user from dual) and mr_type='ORASDPM' and version='11.1.1.2.0'
    ORA-00604: error occurred at recursive SQL level 1
    ORA-01882: timezone region  not found
    CFGFWK-60850:  Test Failed!
    Component Schema=OWSM MDS Schema
    Driver=oracle.jdbc.OracleDriver
    URL=jdbc:oracle:thin:@127.0.0.1:1521/XE
    User=DEV_MDS
    Password=********
    SQL Test=select 1 from schema_version_registry where
                        owner=(select user from dual) and mr_type='MDS' and
                        version='11.1.1.4.0'
    ORA-00604: error occurred at recursive SQL level 1
    ORA-01882: timezone region  not found
    CFGFWK-60850:  Test Failed!
    Component Schema=SOA MDS Schema
    Driver=oracle.jdbc.OracleDriver
    URL=jdbc:oracle:thin:@127.0.0.1:1521/XE
    User=DEV_MDS
    Password=********
    SQL Test=select 1 from schema_version_registry where owner=(select user from dual) and mr_type='MDS' and version='11.1.1.4.0'
    ORA-00604: error occurred at recursive SQL level 1
    ORA-01882: timezone region  not found
    CFGFWK-60850:  Test Failed!
    Component Schema=OSB JMS Reporting Provider
    Driver=org.apache.derby.jdbc.ClientDriver
    URL=jdbc:derby://127.0.0.1:1521/XE;create=true;ServerName=127.0.0.1;databaseName=XE
    User=DEV_SOAINFRA
    Password=********
    SQL Test=SELECT 1 FROM SYS.SYSTABLES
    Insufficient data while reading from the network - expected a minimum of 6 bytes and received only 0 bytes.  The connection has been terminated.
    CFGFWK-60850:  Test Failed!

    Hi,
    Please check the timezone set in your server where Weblogic is installed. Also ensure the timezone on which your weblogic is running, the same is present in in database by querying V$TIMEZONE_NAMES table. If it is not present then please change the timezone of the server. then try to execute the steps what you are doing, it will not throw any error.
    if this helps please mark.
    Thanks,
    Kishore

  • ORA-00604: error occurred at recursive SQL level 1

    Hi,
    i have a view as source (DB2)
    Target table in Oracle with the same structure
    when i view data from the view all the records are listed.
    after mapping the source and target source gets fail while debuging (test data)
    and also while deploying the mapping i get the following error.
    Anyone knows about the following errors
    ACBLODS_MAP
    Create
    Warning
    ORA-06550: line 0, column 0:
    ORA-04052: error occurred when looking up remote object [email protected]@DB2_KAPIL_LOCATION
    ORA-00604: error occurred at recursive SQL level 1
    ORA-28500: connection from ORACLE to a non-Oracle system returned this
    please someone help me to solve this
    thanks in advance
    regards
    raja

    I had a simular problem with progress. If the progress table had to many columns
    OWB was failing. The problem was the ODBC driver used to make a connection to PROGRESS.

  • ORA-00604: error occurred at recursive SQL level 1 (Call to a Oracle View)

    I have created a view that refers to a package function within the sql select.
    Like
    E.x
    CREATE OR REPLACE VIEW VW_TAX
    as select
    test_pkg.fn_get_gl_value(acct_id) desired_col1,
    test_pkg.fn_get_gl_desc_value(acct_id) desired_col2
    From tables a, b
    a.col= b.col
    The sample function( fn_get_gl_value) is embedded into a package (test_pkg).
    Function fn_get_gl_value:
    It earlier referred to table A1, B1, C1 and this query took really long, Therefore I used object type tables and stored the values required once within the package when it is invoked. Later I used the Tables A1, B1 and C1(table Cast from the type Table Loaded in Package Memory)
    The query was fast and fine, but now when I try to re-use the view
    select * from VW_TAX
    where acct_id = '02846'
    It fails with this message
    09:32:35 Error: ORA-00604: error occurred at recursive SQL level 1
    ORA-01000: maximum open cursors exceeded
    Note: The database is Oracle8i Enterprise Edition Release 8.1.7.4.0.
    Maximum cursors database is 500
    Please let me know if there is any known solution,
    Appreciate all your help
    Thanks
    RP

    Seems like your OPEN_CURSORS init.ora parameter is set too low.
    See Metalink Note:1012266.6 for details.
       ORA-01000: "maximum open cursors exceeded"
            Cause: A host language program attempted to open too many cursors.
                   The initialization parameter OPEN_CURSORS determines the
                   maximum number of cursors per user.
           Action: Modify the program to use fewer cursors. If this error occurs
                   often, shut down Oracle, increase the value of OPEN_CURSORS,
                   and then restart Oracle.

  • ORA-00604: error occurred at recursive SQL level

    I only have 2 users and approx 9 schemas.
    Why is this complaining about maximum cursors??
    Error message:
    ORA-00604: error occurred at recursive SQL level
    ORA-01000: maximum open cursors exceeded
    ORA-0064 error occurred at recursive SQL level
    Cause:
    An error occurred at recursive SQl level
    (a statement applying to internal dictionary tables)
    >>
    Created 2 users
    1) boundaries (User)
    has a couple of schema.
    National, provincial, district, village
    I have set-up the Primary & Foreign keys.
    Only 1 table has 1 row of data
    2) Projects (User)
    Set up one table - Program
    Program has a Primary Key.
    Foreign key is linked to (boundaries) national PK
    The problem occured when I entered data into boundaries.national

    Clive_S wrote:
    OS: Windows Server 2008 standard - 64 bit.
    Select * from v$version
    Oracle Database 11g release 11.1.0.7.0 - 64 bit
    PL/SQL release 11.1.0.7.0 - production core 11.1.0.7.0
    Production TNS for 64-bit windows: 11.1.0.7.0
    Production NLSRTL for 64-bit windows: 11.1.0.7.0
    I am trying to replicate in Oracle what I would do in SQL Server. There's your first mistake. There are too many differences. My first programming language was COBOL, but I don't write other languages as if they were COBOL.
    I cannot attach an image of the users & tablespace, to illustrate.Another reason to work in sqlplus.
    >
    I created 2 User = Boundaries and Project
    I created several schemas (tables)No, you created 2 schemas. One user = one schema = one user.
    A schema is not a table and a table is not a schema. A schema is a collection of objects, which can include multiple tables but only those owned by one username.
    >
    Boundaries (user)
    Tables:
    Country
    Province
    District
    Village
    Projects (user)
    Tables:
    Program
    Project.Program has a FK = Country that is linked to Boundaries.Country
    I need to create several scemas (databases):Another difference. a schema is not a database, though the sql server concept of a database is somewhat analogous to an oracle schema.
    Boundaries, Project, Assets.
    There are foreign keys linking the various schemas.FKs link tables not schemas.
    Edited by: EdStevens on Feb 26, 2010 10:30 AM

  • ORA-00604: error occurred at recursive SQL level 1 and ORA-30036:

    Hi Gurus,
    I am trying to shrink the table segment along with indexes.
    I am using
    alter table OWNER.TABLE shrink space cascade; syntax but after 1 hr i got the following error.
    ERROR at line 1:
    ORA-00604: error occurred at recursive SQL level 1
    ORA-30036: unable to extend segment by 4 in undo tablespace 'UNDOTBS01'
    UNDO tablespace has sufficient space and undo_retention is 6Hrs. What could be the problem ?
    Or do i need to use
    alter table OWNER.TABLE shrink space; only ?
    Thanks & Regards

    Hi,
    I am doing this in testing enviornment and before this activity added 4g space to existing 50GB undo tablespace.
    No jobs are running in testing environment and the shrinking on table is of 12GB. I cann't import/export and truncate or move to different tablespaces as this has oracle advanced queue and chances are more to corrupt queues.
    Thanks

Maybe you are looking for

  • Need help with creation of Payment Cycles

    We need you to determine a way to sum up the Measure "Prod Matl - Std" into Payment Cycles of the 5th, 10th, 15th, 20th, 25th and 30th of each month. Company only pays suppliers on the Payment Cycles indicated above. General Rules:                   

  • Download data from db to CSV file and need to handle chinese character

    Hi , all , I need to write to alow to export data from db to csv file, now the problem is some column is chinese character, in both db and web page it can dispaly the chinese, but in Csv I can't display chinese character, what should I do? Thnak you

  • SAP R/3 different versions,  release years

    HI SAP Gurus, Can any body please can give me the details of SAP R/3 releases and its release years . Example : in 2004 or 205 ECC5 is released and in 2006 ECC6 is released, This also i am not sure i am just giving as an example. I just want to know

  • Database Architecture for OnDemand design

    Hi All, We have a custom application and every time for the clients we are giving all our executables and they are installing in their machines. Rather than that we want to have 1 application installed in the server at our side and wants to give doma

  • System init function failed, Uunixerr = : msgget: No such file or directory

    windows Server 2008 Enterprise tuxedo11GR1PS1 when I run command "tmboot -y", I got the following error info at ULOG file: 105806.RNO05045.us.oracle.com!BBL.3536.5040.0: LIBTUX_CAT:681: ERROR: Failure to create message queue 105806.RNO05045.us.oracle