ORA-04091: table POSTAL_ADDRESS is mutating, trigger/function may not see it

First off, there are NO TRIGGERS defined on the table in question in our database.
The process we need to accomplish is as follows:
1.  Load addresses from the table.
2.  Send the addresses through a standardization routine.
3.  Multi-Insert any address that was successfully standardized and is not already present.
So how do I tell ODI 12c to create a temporary table before doing the multi-insert?  So far everything I've tried gets "flattened" and results in the same error.
OR
Is there a different solution?
Thanks for your help,
Scott

I fixed this by creating a second Physical+Logical+Model to the same database (not sure if I needed all three but did it this way to make sure).  This caused ODI to generate a SOURCE_GROUP and TARGET_GROUP instead of just a TARGET_GROUP in the physical view.  Then all I had to do is on the properties of the first item in the target, set the properties on the LKM Oracle to Oracle Pull (DB Link).GLOBAL to whichever option I wanted (USE_STAGE_TABLE or SELECT_FROM_SOURCE_VIEW).  One thing to do is put the database's own SID in the SOURCE_ACCESS_DB_LINK so it doesn't create an unnecessary DB Link.
Hope that helps someone else!

Similar Messages

  • ORA-04091: table AM is mutating, trigger/function may not see it

    I create this trigger:
    CREATE OR REPLACE TRIGGER pr_test
    after insert ON AM
    FOR EACH ROW
    declare
    appo_pr varchar2(64):= null;
    BEGIN
    select name
    into appo_pr
    from AS
    where AS_ID=:new.AS_ID;
    insert into AM (name) values (appo_pr);
    END pr_test;
    I insert before a new AS_ID and name in tab AS but when I insert a new record in tab AM I get this error:
    ORA-04091: table AM is mutating, trigger/function may not see it
    ORA-06512: at PR_TEST", line 11
    ORA-04088: error during execution of trigger PR_TEST'
    I'd like to create a trigger that when I insert a new record in AM It verify the value in col name of AS and insert this value in col name of AM.
    What I wrong in this trigger??
    How can I modify it??
    Thanks
    Raf

    Try this:
    CREATE OR REPLACE TRIGGER pr_test
      before insert ON AM
      FOR EACH ROW
    declare
      appo_pr AS.name%TYPE;
    BEGIN
      select name
      into   appo_pr
      from   AS
      where  AS_ID = :new.AS_ID;
      :new.name = appo_pr;
    END pr_test;

  • ORA-04091:table XYZ is mutating,trigger/function may not see it ORA-06512

    Hi everybody
    i am facing mutating problem during data deletion fron XYZ table as
    ORA-04091:table XYZ is mutating,trigger/function may not see it ORA-06512 at "user.procdure_name",line 39 ORA-065
    i have table XYZ and have database trigger on this table
    and also have procedure "user.abc" in this procedure m selecting data from xyz table

    You didn't post the actual code. I was more interested in seeing table name and the trigger body.
    Anyways, mutation problem comes when you refer the same table on the trigger, on which it is based for some data manipulation on that table.
    For e.g, If inside your trigger body, you are doing INSERT on the same table, then it'll definitely result in mutation problem because this trigger will be fired endlessly (as it is after insert trigger).
    Please mark answer as helpful / correct, if it helps you
    Navnit

  • ORA-04091: table ACCESSLOG is mutating, trigger/function may not see it

    Hi
    Got the following error
    ORA-04091: table ACCESSLOG is mutating, trigger/function may not see it
    i searched the error found that the problem is with FOR EACH ROW
    how can i handel this specifically with the following code:
    CREATE OR REPLACE TRIGGER EMP_ACCESS
    AFTER INSERT
    ON ACCESSLOG
    REFERENCING NEW AS NEW OLD AS OLD
    FOR EACH ROW
    DECLARE
    tmpVar NUMBER;
    BEGIN
    IF ( :NEW.INOUT = 'OUT' ) THEN
    SELECT 'X'
    INTO tmpVar
    FROM ACCESSLOG
    WHERE EMPLOYEEID = :NEW.EMPLOYEEID
    AND LOGDATE = :NEW.LOGDATE
    AND INOUT ='IN' ;
    IF tmpVar IS NULL THEN
    INSERT INTO Emp_All_Moves_Absent (
    EMP_NO,
    ATT_DATE,
    ATT_FLAG,
    ATT_TIME_IN,
    ATT_TIME_OUT,
    VAC_COD,
    MIS_CODE,
    DAY_FLAG ,
    POSTEDFLAG,
    ATT_TIME_IN_PLANNED,ATT_TIME_OUT_PLANNED)
    VALUES
    (to_number(to_char(:NEW.employeeid,99999)),
    TO_DATE(:NEW.LOGDATE,'DD/MM/YYYY'),
    'ABS' ,
    to_date(:NEW.LOGTIME,'HH24:MI:SS'),
    to_date(:NEW.LOGTIME,'HH24:MI:SS'),
    NULL,
    NULL,
    'WORK',
    0,
    NULL,NULL);
    END IF;
    ELSIF ( :NEW.INOUT = 'IN' ) THEN
    SELECT 'X'
    INTO tmpVar
    FROM ACCESSLOG
    WHERE EMPLOYEEID = :NEW.EMPLOYEEID
    AND LOGDATE = :NEW.LOGDATE-1
    AND INOUT ='IN' ;
    IF tmpVar IS NULL THEN
    INSERT INTO Emp_All_Moves_Absent (
    EMP_NO,
    ATT_DATE,
    ATT_FLAG,
    ATT_TIME_IN,
    ATT_TIME_OUT,
    VAC_COD,
    MIS_CODE,
    DAY_FLAG ,
    POSTEDFLAG,
    ATT_TIME_IN_PLANNED,ATT_TIME_OUT_PLANNED)
    VALUES
    (to_number(to_char(:NEW.employeeid,99999)),
    TO_DATE(:NEW.LOGDATE-1,'DD/MM/YYYY'),
    'ABS' ,
    to_date(:NEW.LOGTIME,'HH24:MI:SS'),
    to_date(:NEW.LOGTIME,'HH24:MI:SS'),
    NULL,
    NULL,
    'WORK',
    0,
    NULL,NULL);
    END IF;
    END IF;
    EXCEPTION
    WHEN OTHERS THEN
    -- Consider logging the error and then re-raise
    RAISE;
    END EMP_ACCESS_LOG_OUT;
    Urgent help is highly appreciated..
    Regards,
    Abdetu..

    Thanks Jens Petersen for reply
    now i want to make sure of one thing that i have to follow the steps but the last one i will replace it with my trigger NO?
    SQL> create or replace package state_pkg
    2 as
    3 type ridArray is table of rowid index by binary_integer;
    4
    4 newRows ridArray;
    5 empty ridArray;
    6 end;
    7 /
    Package created.
    SQL> create or replace trigger parent_bi
    2 before insert or update on parent
    3 begin
    4 state_pkg.newRows := state_pkg.empty;
    5 end;
    6 /
    Trigger created.
    SQL> create or replace trigger parent_aifer
    2 after insert or update of status on parent for each row
    3 begin
    4 state_pkg.newRows( state_pkg.newRows.count+1 ) := :new.rowid;
    5 end;
    6 /
    Trigger created.
    ---------------------now come my trigger instead of the following one ??---------------
    SQL> create or replace trigger parent_ai
    2 after insert or update of status on parent
    3 begin
    4 for i in 1 .. state_pkg.newRows.count loop
    5 insert into log_table
    6 select theKey, status, effDate
    7 from parent where rowid = state_pkg.newRows(i);
    8 end loop;
    9 end;
    10 /
    Trigger created.
    Regards,
    Abdetu..

  • ORA-04091: table name is mutating, trigger/function may not see it

    Hi,
    I have a row level before update trigger written on a table A which calls a procedure to undergo some processing. Procedure has some select queries against table A and it inturn causes the following error.
    ORA-04091: table name is mutating, trigger/function may not see it
    To overcome this I have used a combination of PL/SQL collection types (nested tables based on the following definition TYPE t_table_a is table of A.colname%TYPE index by binary_integer;), a row level before update trigger and statement level after update trigger. The mutating problem is fixed, but to update one row of data it took around 3 min and I am wondering if its the problem with PL/SQL tables I have used.
    In before update trigger I am storing the unique id's which needs to be updated into the PL/SQL table and in the after update trigger I am looping through the PL/SQL table and peforming the rest of the processing by calling in the procedure.
    Can anyone help how to minimize the run time of this process or if any other better solution exists?
    Thanks for the help

    Triggers raise the mutating table issue, because else they could be used to create endless loops. If you work around the mutating table issue, then you should make sure not to create an endless loop yourself. This would be possible.
    You description also seems to imply something like this.
    Without code it is impossible to say something specific.
    - Do you initialize your collection in a before statement trigger?
    - Is your looping mechanism somehow broken?
    - Do you update the same table again and again and again?

  • ORA-04091: table blah is mutating, trigger/function may not see it

    ORA-04091: table blah is mutating, trigger/function may not see it
    ORA-06512: at "AOLALERE.CHK_FOR_POST", line 7
    ORA-06512: at "AOLALERE.CHK_FOR_POST", line 20
    ORA-06512: at "AOLALERE.PREPRODDTA_F41021_AFTER_UPDATE", line 14
    ORA-04088: error during execution of trigger 'AOLALERE.PREPRODDTA_F41021_AFTER_UPDATE'
    TRIGGER preproddta_f41021_after_update
    after insert or update
    on preproddta.f41021
    for each row
    declare
    --nothing to declare
         --pragma autonomous_transaction;
         l_lipqoh preproddta.f41021.lipqoh%type;
         l_lipcom preproddta.f41021.lipcom%type;
         l_lihcom preproddta.f41021.lihcom%type;
         l_lilots preproddta.f41021.lilots%type;
         l_lilocn preproddta.f41021.lilots%type;
         l_lilotn preproddta.f41021.lilots%type;
    l_quantity_avail f41021_audit.quantity_avail%type;
         l_rec_chk f41021_audit.liitm%type;
    begin
    --chk_for_post(:new.limcu,:new.liitm);
    --if :old.limcu <> '      GBD001' then return; end if;
    if :old.lipqoh = :new.lipqoh then
    l_lipqoh := :old.lipqoh;
    else
    l_lipqoh := :new.lipqoh;
    end if;
    if :old.lipcom = :new.lipcom then
    l_lipcom := :old.lipcom;
    else
    l_lipcom := :new.lipcom;
    end if;
    if :old.lihcom = :new.lihcom then
    l_lihcom := :old.lihcom;
    else
    l_lihcom := :new.lihcom;
    end if;
    if :old.lilots = :new.lilots then
    l_lilots := :old.lilots;
    else
    l_lilots := :new.lilots;
    end if;
    if l_lilots <> ' ' then
    l_quantity_avail := - (l_lipcom - l_lihcom);
    else
    l_quantity_avail := l_lipqoh - (l_lipcom + l_lihcom);
    end if;
    l_rec_chk := rec_chk(:old.limcu,:old.liitm,l_lilots);
    if l_rec_chk is not null then
         begin
    update f41021_audit
         set lipqoh = l_lipqoh,
         lipcom = l_lipcom,
    lihcom = l_lihcom,
              quantity_avail = l_quantity_avail
         where limcu = :old.limcu
         and liitm = :old.liitm
         and lilotn = :old.lilotn
         and lilocn = :old.lilocn
         and lilots = l_lilots;
         end;
    else
    -- insert record into audit table
    begin
    insert into f41021_audit
    (limcu,
                        liitm,
                                  lipqoh,
                                  lipcom,
                                  lihcom,
                                  lilots,
                                       lilotn,
                                       lilocn,
                                       quantity_avail)
    values
    (:old.limcu,
    :old.liitm,
    l_lipqoh,
                                  l_lipcom,
                                  l_lihcom,
                                  l_lilots,
                                       :old.lilotn,
                                       :old.lilocn,
                                       l_quantity_avail);
         end;
    end if;
    end;
    create or replace procedure chk_for_post(p_limcu in varchar2,
    p_liitm in number)
    is
    cursor get_bra_qa(p_limcu in varchar2,
    p_liitm in number)is
    select liitm,
         (sum(lipqoh) - sum(lipcom + lihcom)) qual_avail
    from preproddta.f41021 a, preproddta.f4101 b
    where limcu = p_limcu
    and liitm = imitm
    and liitm = p_liitm
    group by liitm,imdsc1;
    l_bra_qa get_bra_qa%rowtype;
    l_itm_bran_qa t_f41021_itm_bran_qa := t_f41021_itm_bran_qa.initialize(p_liitm);
    begin
    open get_bra_qa(p_limcu,p_liitm);
    fetch get_bra_qa into l_bra_qa;
    close get_bra_qa;
    if l_itm_bran_qa.quantity_avail is null then ---This indicate that there is no record for
    ---quantity available for the item based on the branch .
    l_itm_bran_qa := new t_f41021_itm_bran_qa(p_liitm);
         begin
         l_itm_bran_qa.liitm := p_liitm;
         l_itm_bran_qa.limcu := p_limcu;
         l_itm_bran_qa.quantity_avail := l_bra_qa.qual_avail;
         l_itm_bran_qa.add_it;
         commit;
         end;     
    else
    l_itm_bran_qa := t_f41021_itm_bran_qa.initialize(p_liitm);
         if l_itm_bran_qa.quantity_avail = l_bra_qa.qual_avail then
         null; return;
         else
         begin
         l_itm_bran_qa.liitm := p_liitm;
         l_itm_bran_qa.limcu := p_limcu;
         l_itm_bran_qa.quantity_avail := l_bra_qa.qual_avail;
         l_itm_bran_qa.send_to_DB;
         commit;
         end;
         end if;     
    end if;
    end;

    Thanks,
    I comment it out cos it was causing the problem this is the code:
    The following error has occurred:
    ORA-04091: table PREPRODDTA.F41021 is mutating, trigger/function may not see it
    ORA-06512: at "AOLALERE.CHK_FOR_POST", line 7
    ORA-06512: at "AOLALERE.CHK_FOR_POST", line 20
    ORA-06512: at "AOLALERE.PREPRODDTA_F41021_AFTER_UPDATE", line 98
    ORA-04088: error during execution of trigger 'AOLALERE.PREPRODDTA_F41021_AFTER_UPDATE'
    TRIGGER preproddta_f41021_after_update
    after insert or update
    on preproddta.f41021
    for each row
    declare
    --nothing to declare
         --pragma autonomous_transaction;
         l_lipqoh preproddta.f41021.lipqoh%type;
         l_lipcom preproddta.f41021.lipcom%type;
         l_lihcom preproddta.f41021.lihcom%type;
         l_lilots preproddta.f41021.lilots%type;
         l_lilocn preproddta.f41021.lilots%type;
         l_lilotn preproddta.f41021.lilots%type;
    l_quantity_avail f41021_audit.quantity_avail%type;
         l_rec_chk f41021_audit.liitm%type;
    begin
    --if :old.limcu <> '      GBD001' then return; end if;
    if :old.lipqoh = :new.lipqoh then
    l_lipqoh := :old.lipqoh;
    else
    l_lipqoh := :new.lipqoh;
    end if;
    if :old.lipcom = :new.lipcom then
    l_lipcom := :old.lipcom;
    else
    l_lipcom := :new.lipcom;
    end if;
    if :old.lihcom = :new.lihcom then
    l_lihcom := :old.lihcom;
    else
    l_lihcom := :new.lihcom;
    end if;
    if :old.lilots = :new.lilots then
    l_lilots := :old.lilots;
    else
    l_lilots := :new.lilots;
    end if;
    if l_lilots <> ' ' then
    l_quantity_avail := - (l_lipcom - l_lihcom);
    else
    l_quantity_avail := l_lipqoh - (l_lipcom + l_lihcom);
    end if;
    l_rec_chk := rec_chk(:old.limcu,:old.liitm,l_lilots);
    if l_rec_chk is not null then
         begin
    update f41021_audit
         set lipqoh = l_lipqoh,
         lipcom = l_lipcom,
    lihcom = l_lihcom,
              quantity_avail = l_quantity_avail
         where limcu = :old.limcu
         and liitm = :old.liitm
         and lilotn = :old.lilotn
         and lilocn = :old.lilocn
         and lilots = l_lilots;
         end;
    else
    -- insert record into audit table
    begin
    insert into f41021_audit
    (limcu,
                        liitm,
                                  lipqoh,
                                  lipcom,
                                  lihcom,
                                  lilots,
                                       lilotn,
                                       lilocn,
                                       quantity_avail)
    values
    (:old.limcu,
    :old.liitm,
    l_lipqoh,
                                  l_lipcom,
                                  l_lihcom,
                                  l_lilots,
                                       :old.lilotn,
                                       :old.lilocn,
                                       l_quantity_avail);
         end;
    end if;
    chk_for_post(:new.limcu,:new.liitm);
    return;
    end;
    create or replace procedure chk_for_post(p_limcu in varchar2,
    p_liitm in number)
    is
    cursor get_bra_qa(p_limcu in varchar2,
    p_liitm in number)is
    select liitm,
    (sum(lipqoh) - sum(lipcom + lihcom)) qual_avail
    from preproddta.f41021 a, preproddta.f4101 b
    where limcu = p_limcu
    and liitm = imitm
    and liitm = p_liitm
    group by liitm,imdsc1;
    l_bra_qa get_bra_qa%rowtype;
    l_itm_bran_qa t_f41021_itm_bran_qa := t_f41021_itm_bran_qa.initialize(p_liitm);
    begin
    open get_bra_qa(p_limcu,p_liitm);
    fetch get_bra_qa into l_bra_qa;
    close get_bra_qa;
    if l_itm_bran_qa.quantity_avail is null then ---This indicate that there is no record for
    ---quantity available for the item based on the branch .
    l_itm_bran_qa := new t_f41021_itm_bran_qa(p_liitm);
    begin
    l_itm_bran_qa.liitm := p_liitm;
    l_itm_bran_qa.limcu := p_limcu;
    l_itm_bran_qa.quantity_avail := l_bra_qa.qual_avail;
    l_itm_bran_qa.add_it;
    commit;
    end;
    else
    l_itm_bran_qa := t_f41021_itm_bran_qa.initialize(p_liitm);
    if l_itm_bran_qa.quantity_avail = l_bra_qa.qual_avail then
    null; return;
    else
    begin
    l_itm_bran_qa.liitm := p_liitm;
    l_itm_bran_qa.limcu := p_limcu;
    l_itm_bran_qa.quantity_avail := l_bra_qa.qual_avail;
    l_itm_bran_qa.send_to_DB;
    commit;
    end;
    end if;
    end if;
    end;
    Please sugesst any work around. I need to call calculate changes based on the insert or updates

  • ORA-04091: table OBJ_SIGN_TRANS is mutating, trigger/function may not..

    Hi ,
    I m getting table mutating error while trying to update this table, i m doing transaction signing from Java mehtod, table has 2 triggers, whlie updating this table i m facing error. Triggers are mentioned bellow including a package which i m using global variables and table description too.
    CREATE OR REPLACE PACKAGE pck$mutations
    IS
    Gv_ref_id varchar2(50);
    Gv_line_no number;
    Gv_ref_ser varchar2(6);
    Gv_sign_Status char(1);
    END pck$mutations;
    CREATE OR REPLACE TRIGGER trig_obj_sign_Trans
    BEFORE UPDATE ON obj_sign_trans
    FOR EACH ROW
    BEGIN
    Pck$mutations.Gv_ref_id :=:NEW.ref_id;
    Pck$mutations.Gv_ref_ser :=:NEW.ref_ser;
    Pck$mutations.Gv_line_no :=:NEW.line_no;
    Pck$mutations.Gv_sign_status :=:NEW.sign_status;
    END;
    CREATE OR REPLACE TRIGGER aft_obj_sign_Trans
    AFTER UPDATE ON OBJ_SIGN_TRANS
    DECLARE
    CURSOR c_ref_id
    IS SELECT line_no,ref_id
    FROM obj_sign_trans
    WHERE ref_ser= RTRIM(pck$mutations.Gv_ref_ser)
              AND ref_id = pck$mutations.Gv_ref_id
              AND LINE_NO <>pck$mutations.Gv_LINE_NO;
    dest_lob BLOB;
    src_lob BLOB;
              dest_lob_len number(14,3);
              src_lob_len number(14,3);
    BEGIN
    For i in c_ref_id
    loop
              SELECT trans_info ,dbms_lob.getlength(trans_info)
                   INTO src_lob,src_lob_len
              FROM OBJ_SIGN_tRANS
              WHERE REF_ID=pck$mutations.Gv_ref_id
                   AND REF_SER=RTRIM(pck$mutations.Gv_ref_ser)
                   AND LINE_NO=pck$mutations.Gv_line_no;
              DBMS_OUTPUT.PUT_LINE(TO_CHAR(src_lob_len ));
              DBMS_OUTPUT.PUT_LINE(pck$mutations.Gv_line_no);
              DBMS_OUTPUT.PUT_LINE('SELECTED SOURCE ...............');
    -- EXIT WHEN c_ref_id%NOTFOUND;
              SELECT trans_info,dbms_lob.getlength(trans_info)
                   INTO dest_loB,dest_lob_len
              FROM OBJ_SIGN_tRANS
              WHERE REF_ID=pck$mutations.Gv_ref_id
                   AND REF_SER=RTRIM(pck$mutations.Gv_ref_ser)
              AND LINE_NO =I.LINE_NO FOR UPDATE;
              DBMS_OUTPUT.PUT_LINE(TO_CHAR(dest_lob_len) );
                   DBMS_LOB.ERASE(dest_lob,dest_lob_len,1);
                   DBMS_LOB.WRITE(dest_lob,src_lob_len,1,src_lob);
                   DBMS_OUTPUT.PUT_LINE(I.LINE_NO );
              DBMS_OUTPUT.PUT_LINE(pck$mutations.Gv_ref_id );
              DBMS_OUTPUT.PUT_LINE('UPDATED...............');
              end loop ;
         END;
    SQL> desc obj_sign_trans
    Name Null? Type
    REF_SER NOT NULL VARCHAR2(6)
    REF_ID NOT NULL VARCHAR2(50)
    LINE_NO NOT NULL NUMBER(3)
    SIGN_FOR VARCHAR2(100)
    ROLE_CODE__SIGN VARCHAR2(10)
    SIGN_DATE DATE
    USER_ID__SIGN VARCHAR2(10)
    SIGN_REMARKS VARCHAR2(100)
    CERT_NO VARCHAR2(200)
    SIGN_STATUS CHAR(1)
    TITLE VARCHAR2(50)
    EMP_CODE CHAR(10)
    CREATE_DATE DATE
    TRANS_INFO BLOB
    ROLE_TYPE VARCHAR2(1)
    ROLE_ENTITY VARCHAR2(1)
    ENTITY_CODE CHAR(10)
    PRC_INST__WF VARCHAR2(50)
    can anyone help me with this regard.
    your prompt help would be appriciated.
    regards
    qamar

    Please see the below
    How to solve mutating error
    cheers

  • Rgding ORA-04091:table PURCHSE_DTL is mutating,trigger/function maynot c it

    I wrote a trigger 'TRG_PURCHASE_DTL' to update the stock table 'BRANCH_ITEM_STOCK' based on the DML actions perfomed on tables PURCHASE_DTL and ISSUE_DTL, but I am getting following error:-
    ORA-04091: table PURCHASE_DTL is mutating, trigger/function may not see it
    and the value of 'BRANCH_ITEM_STOCK.purchase_qty' is updated to 10 instead of 18.
    The table structure and data is given below:
    -- ============================================================
    -- Table: BRANCH_ITEM_STOCK
    -- ============================================================
    create table BRANCH_ITEM_STOCK
    BRANCH_CODE NUMBER(6) not null,
    ITEM_CODE NUMBER(6) not null,
    PURCHASE_QTY NUMBER(6) null ,
    RECEIPT_QTY NUMBER(6) null ,
    ISSUE_QTY NUMBER(6) null ,
    BALANCE_QTY NUMBER(6) null ,
    REMARKS VARCHAR2(100) null ,
    constraint PK_RA25_BRANCH_ITEM_STOCK primary key (BRANCH_CODE, ITEM_CODE)
    -- ============================================================
    -- Table: PURCHASE_MST
    -- ============================================================
    create table PURCHASE_MST
    BRANCH_CODE NUMBER(6) not null,
    PURCHASE_YR NUMBER(6) not null,
    PURCHASE_NO NUMBER(6) not null,
    PURCHASE_DT DATE not null,
    QUOTATION_NO NUMBER(6) not null,
    QUOTATION_YR NUMBER(4) not null,
    VENDOR_CODE NUMBER(6) not null,
    RECEIPT_NO VARCHAR2(25) null ,
    constraint PK_PURCHASE_HDR primary key (BRANCH_CODE, PURCHASE_YR, PURCHASE_NO)
    -- ============================================================
    -- Table: PURCHASE_DTL
    -- ============================================================
    create table PURCHASE_DTL
    BRANCH_CODE NUMBER(6) not null,
    PURCHASE_YR NUMBER(6) not null,
    PURCHASE_NO NUMBER(6) not null,
    REC_SNO NUMBER(6) not null,
    ITEM_CODE NUMBER(6) not null,
    ITEM_QTY NUMBER(6) not null,
    ITEM_PRICE NUMBER not null,
    ITEM_AMT NUMBER not null,
    constraint PK_PURCHASE_DTL primary key (BRANCH_CODE, PURCHASE_YR, PURCHASE_NO, REC_SNO)
    -- ============================================================
    -- Table: ISSUE_MST
    -- ============================================================
    create table ISSUE_HDR
    BRANCH_CODE NUMBER(6) not null,/* Issued from Branch*/
    ISSUE_YR NUMBER(6) not null,
    ISSUE_NO NUMBER(6) not null,
    ISSUE_DT DATE not null,
    ISSUED_BY VARCHAR2(15) not null,
    ISSUED_TO_BRANCH VARCHAR2(15) not null,
    ISSUE_STATUS NUMBER(6) null,
    constraint PK_ISSUE_HDR primary key (BRANCH_CODE, ISSUE_YR, ISSUE_NO)
    -- ============================================================
    -- Table: ISSUE_DTL
    -- ============================================================
    create table ISSUE_DTL
    BRANCH_CODE NUMBER(6) not null,
    ISSUE_YR NUMBER(6) not null,
    ISSUE_NO NUMBER(6) not null,
    REC_SNO VARCHAR2(25) not null,
    ITEM_CODE NUMBER(6) not null,
    ITEM_DTL VARCHAR2(400) null ,
    ITEM_QTY NUMBER(6) null ,
    RECEIPT_QTY NUMBER(6) null ,
    constraint PK_RA25_ISSUE_DTL primary key (BRANCH_CODE, ISSUE_YR, ISSUE_NO, REC_SNO)
    Assume that the Contents of PURCHASE_MST is as follows:
    SELECT branch_code, purchase_yr, purchase_no FROM PURCHASE_HDR;
    BRANCH_CODE PURCHASE_YR PURCHASE_NO     
    100          2008          1     
    100          2009          1     
    100          2009          2     
    Now I tried to insert follwing values to the PURCHASE_DTL table:
    insert into purchase_dtl (BRANCH_CODE,PURCHASE_YR,PURCHASE_NO,rec_sno,
    ITEM_CODE,item_QTY)
    Values (100,2008,1,1,4,5)
    insert into purchase_dtl (BRANCH_CODE,PURCHASE_YR,PURCHASE_NO,rec_sno,
    ITEM_CODE,item_QTY)
    Values (100,2009,1,1,4,2)
    insert into purchase_dtl (BRANCH_CODE,PURCHASE_YR,PURCHASE_NO,rec_sno,
    ITEM_CODE,item_QTY)
    Values (100,2009,2,1,4,6)
    commit
    Now Contents of table ' PURCHASE_DTL ' is as follows:
    BRANCH_CODE PURCHASE_YR PURCHASE_NO     REC_SNO ITEM_CODE     ITEM_QTY
    100          2008          1     1          4     5
    100          2009          1     1          4     2
    100          2009          2     1          4     6
    I want to write a trigger which will insert/update/delete data into/from BRANCH_ITEM_STOCK,
    so that the contents of column Purchase_qty of table BRANCH_ITEM_STOCK should be as follows:
    BRANCH_CODE     ITEM_CODE     PURCHASE_QTY     RECEIPT_QTY     ISSUE_QTY     BALANCE_QTY
    100          4          13          0          0          13
    [Note:  i.e BRANCH_ITEM_STOCK.PURCHASE_QTY = SUM(PURCHASE_DTL.item_qty) 
         where PURCHASE_DTL.branch_code=100
         AND PURCHASE_DTL.item_code=4
    Now run the following update statement.
    update purchase_dtl
    set item_qty= 10
    where BRANCH_code=100
    and purchase_yr in ( 2008) and purchase_no =1 and rec_sno = 1 AND item_code = 4
    commit
    Now the actual contents of column Purchase_qty of table BRANCH_ITEM_STOCK should be updated as follows:
    BRANCH_CODE     ITEM_CODE     PURCHASE_QTY     RECEIPT_QTY     ISSUE_QTY     BALANCE_QTY
    100          4          18          0          0          18
    But I am facing problem here. I am getting following error:-
    ORA-04091: table PURCHASE_DTL is mutating, trigger/function may not see it
    and the value of purchase qty is updated to 10 instead of 18
    Similarly if any issue of items happen (for eg:- issue_qty=2 to branch_code 200), then the purchase_qty =18,issue_qty=2 , balance_qty:=18-2=16 .
    So for branch_code 200 , receipt_qty = 2.
    Pls help me how to achieve the above .
    Source code which I tried is given below : (but confused at the end )..please help
    CREATE OR REPLACE TRIGGER trg_purchase_dtl
    BEFORE INSERT ON PURCHASE_DTL
    for each row
    declare
    -- local variables here
    l_qty number(6);
    l_cnt NUMBER;
    BEGIN
    BEGIN
    SELECT COUNT(*) into l_cnt
    FROM BRANCH_item_stock b
    WHERE b.BRANCH_code = :new.BRANCH_code
    AND b.item_code = :new.item_code ;
    dbms_output.put_line('1.after selet cnt= '||l_cnt);
    EXCEPTION when no_data_found then
    l_cnt := 0;
    dbms_output.put_line('2.in expt NDF selet cnt= '||l_cnt);
    null;
    END;
    IF INSERTING THEN
    dbms_output.put_line('3.before if ...going to insert ');
    IF l_cnt = 0 THEN
    dbms_output.put_line('hihhiii.......lcnt=0...item_code='||:old.item_code||'~l_qty='||l_qty);
    IF INSERTING THEN
         INSERT INTO BRANCH_ITEM_STOCK
    (BRANCH_code,Item_Code, PURCHASE_QTY,RECEIPT_QTY, issue_qty, balance_qty)
         VALUES(:NEW.BRANCH_code,:NEW.Item_Code, :NEW.ITEM_QTY,0, 0, 0);
    END IF;
    ELSIF l_cnt >0 THEN
    SELECT purchase_qty into l_qty
    FROM BRANCH_Item_Stock
    WHERE BRANCH_code = :new.BRANCH_code
    AND item_code = :new.item_code ;
    l_qty := l_qty + :NEW.ITEM_QTY;
    dbms_output.put_line('6.after selet qty= '||l_qty ||'~new qty='||:NEW.ITEM_QTY||'~old qty='||:OLD.ITEM_QTY);
    dbms_output.put_line('7.before update '||l_qty);
    -- IF INSERTING OR UPDATING THEN
    UPDATE BRANCH_ITEM_STOCK
              SET PURCHASE_QTY = l_qty
              WHERE BRANCH_code = :new.BRANCH_code
    AND item_code = :new.item_code ;
    dbms_output.put_line('8.after update= '||l_qty);
    --END IF;
    END IF;
    END IF; -- end of INSERTING
    -- END;
    --EXCEPTION WHEN DUP_VAL_ON_INDEX THEN
         IF UPDATING THEN
              dbms_output.put_line('9.if UPDATING...qty= '||l_qty ||'~new qty='||:NEW.ITEM_QTY||'~old qty='||:OLD.ITEM_QTY);
    BEGIN
    dbms_output.put_line('~old unotcode='||:old.BRANCH_code||'~old.item_code='||:OLD.ITEM_CODE||'~old itemqty='||:old.item_qty);
    dbms_output.put_line('~new unotcode='||:new.BRANCH_code||'~new.item_code='||:new.ITEM_CODE||'~new itemqty='||:new.item_qty);
    SELECT NVL(SUM(item_qty), 0) into l_qty
         FROM Ra25_Purchase_Dtl
         WHERE BRANCH_code IN ( :old.BRANCH_code )
         AND item_code in ( :old.item_code)
         AND item_qty <> :old.item_code ;
    EXCEPTION WHEN OTHERS THEN
    dbms_output.put_line('10.in EWO'||sqlerrm);
    END;
    --l_qty := l_qty + :NEW.ITEM_QTY;         
    dbms_output.put_line('11.after selet qty= '||l_qty ||'~new qty='||:NEW.ITEM_QTY||'~old qty='||:OLD.ITEM_QTY);
         UPDATE BRANCH_ITEM_STOCK
              SET PURCHASE_QTY = l_qty      --:new.item_qty
              WHERE BRANCH_code = :old.BRANCH_code
              AND item_code = :old.item_code ;
              dbms_output.put_line('13.after update ');
         END IF;
    IF DELETING THEN
    DELETE FROM BRANCH_ITEM_STOCK
    WHERE BRANCH_CODE = :OLD.BRANCH_code
    AND ITEM_CODe = :OLD.item_code;
    END IF;
    end trg_purchase_dtl;
    Please help me how to resolve this problem asap.
    -------------------------------------------------------------------------------------------------------------------------------------------------

    Hi,
    Welcome to the forum!
    See this thread [Avoiding Mutating Tables|http://asktom.oracle.com/tkyte/Mutate/index.html]
    Tip: to preserve formatted code enclose it between {noformat}{noformat} tags (start and end tags are the same) :)
    Thank you for posting DDL and DML of basic data, all people that post should follow this approach.
    Regards,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • ORA-04091: table is mutating, trigger/function may not see

    Hello All,
    I am not an expert in oracle and I have been facing a problem where I get a message as follows :
    ORA-04091: table <table> is mutating, trigger/function may not see it
    I have a table tab1 which has ID, name, and some other columns. the rows in this table form a parent-child type relationship based on some columns within that table. I have created another table called relationship table. The relationship table has 2 columns ID and parentID. I keep this table up to date using triggers. For example if a new record is inserted or upadted in tab1 which affects the parent - child relationship, i update the relationship table accordingly using an insert / update trigger and it works fine.
    I created another trigger as follows
    create or replace trigger MY_DELETE_TRIGGER
    after delete on tab1
    for each row
    BEGIN
    update relationships a set a.parentID = null where a.parentID = :OLD.ID;
    delete from relationships a where a.id = :OLD.ID;
    END MY_DELETE_TRIGGER;
    Basically what I am doing is, the record once deleted, if it was parent of anybody else, i am setting the parent as null and the record itself, if it was in the relationships as a child, I am removing that row.
    This is when I get the table is mutating error, and I don't know how to fix it.
    Can anybody please help me,
    Thanks in advance

    Could you provide more details?
    SQL> select * from tab1;
            ID NAME
             1 test1
             2 test2
    SQL> select * from relationships;
            ID   PARENTID
             1          1
             2          1
    SQL> create or replace trigger MY_DELETE_TRIGGER
      2  after delete on tab1
      3  for each row
      4  BEGIN
      5  update relationships a set a.parentID = null where a.parentID = :OLD.ID;
      6  delete from relationships a where a.id = :OLD.ID;
      7  END MY_DELETE_TRIGGER;
      8  /
    Trigger created.
    SQL> delete from tab1
      2  where id = 1;
    1 row deleted.
    SQL> select * from relationships;
            ID   PARENTID
             2
    SQL> rollback;
    Rollback complete.
    SQL> insert into relationships values(1,1);
    1 row created.
    SQL> select * from relationships;
            ID   PARENTID
             1          1
             2          1
             1          1
    SQL> delete from tab1
      2  where id = 1;
    1 row deleted.
    SQL> select * from relationships;
            ID   PARENTID
             2
    SQL> disconnect
    Disconnected from Oracle9i Enterprise Edition Release 9.2.0.3.0 - 64bit Production
    With the Partitioning option
    JServer Release 9.2.0.3.0 - Production

  • ORA-04091: table ... is mutating, trigger/function may not see it

    Hi,
    I keep getting this error message for my trigger when performing an
    insert..select statement (standard plain old insert works):
    ORA-04091: table ... is mutating, trigger/function may not see it
    The trigger is as follows:
    CREATE OR REPLACE TRIGGER MYTABLE_BEF_INS_CHECK
    BEFORE INSERT ON MYTABLE
    DECLARE
    v_o_id number(10);
    BEGIN
    IF :new.TYP = 'O' THEN
    SELECT 1
         INTO v_o_id
         FROM MYTABLE WHERE TYP = 'O' AND ID=:new.ID;
    END IF;
    END;
    The thing is the trigger works fine for a standard insert like:
    insert into MYTABLE( id,typ)
    values(426672,'O')
    No problem the above works. But when I try an insert select..it
    fails.
    insert into MYTABLE( id,typ)
    SELECT x_id, 'O' from AnyOtherTable;
    the above will fail.
    Anyone an idea why this is the case??
    thx.

    Hi,
    OK OK !!!! This was a copy/paste error. FOR EACH ROW was just not pasted here. Full trigger again:
    CREATE OR REPLACE TRIGGER MYTABLE_BEF_INS_CHECK
    BEFORE INSERT ON MYTABLE
    for each row
    DECLARE
    v_o_id number(10);
    BEGIN
    IF :new.TYP = 'O' THEN
    SELECT 1
         INTO v_o_id
         FROM MYTABLE WHERE TYP = 'O' AND ID=:new.ID;
    END IF;
    END;
    But I want to know why I DO NOT get this problem with the standard insert statement but only with the insert...select.
    thx.
    S.

  • ORA-04091: is mutating, trigger/function may not see

    I am getting this error
    ORA-04091: table SATURN.SARQUAN is mutating, trigger/function may not see it
    ORA-06512: at "BANINST1.F_GETSARQUANSEQNO", line 24
    ORA-06512: at "BANINST1.F_GETSARQUANSEQNO", line 30
    I am trying to do this insert
    INSERT INTO sarquan
                            (sarquan_pidm,sarquan_term_code_entry,sarquan_seqno,
                             sarquan_appl_no, sarquan_question,
                             sarquan_answer, sarquan_activity_date,
                             sarquan_user_id
                    SELECT spriden_pidm,'201090',BANINST1.F_GETSARQUANSEQNO(spriden_pidm,'201090','1'),'1',
                     'Would you prefer September admission?',
                    DECODE (szcasup_sept_adm, 'Y', 'Yes', 'N', 'No'),sysdate,'rmanoei'
               FROM saturn_midd.szcasup, saturn.spriden
              WHERE spriden_id = szcasup_common_appl_id
                AND spriden_ntyp_code = 'CAPP'
                AND (   szcasup_sept_adm IS NOT NULL
                     OR szcasup_feb_adm IS NOT NULL
                     OR szcasup_interview IS NOT NULL
                AND NOT EXISTS (
                       SELECT *
                         FROM  sarquan
                        WHERE sarquan_pidm = spriden_pidm
                          AND spriden_ntyp_code = 'CAPP'
                          AND sarquan_term_code_entry = '201090');
                          I got data when I ran just the select statement, none of the records have data in the sarquan table.
    I got data when I select from this function
    ,BANINST1.F_GETSARQUANSEQNO(spriden_pidm,'201090','1'),'1'
    Any ideas?
    Edited by: peace4all on Aug 12, 2009 4:49 PM

    I can not drop the trigger, I don't own the trigger, it is in production, SARQUAN is a production table
    Now I am getting this error ORA-04091: table SATURN.SARQUAN is mutating, trigger/function may not see it
    ORA-06512: at "BANINST1.F_GETSARQUANSEQNO", line 24
    ORA-06512: at "BANINST1.F_GETSARQUANSEQNO", line 30
    ORA-06512: at "SATURN.ST_SARQUAN_INSERT_ROW", line 2
    ORA-04088: error during execution of trigger 'SATURN.ST_SARQUAN_INSERT_ROW'
    when I do the following
    I know that this pidm does not have any records in the table SARQUAN
    spriden_pidm = 2287953
    So I try to do a simple insert, not using the function, now I am hardcoding the seq, I know it needs to be 1 since there are not records in that table yet,
    the sequence go by pidm
    INSERT INTO saturn.sarquan
                     sarquan_pidm,
                     sarquan_seqno,
                     sarquan_term_code_entry,
                     sarquan_appl_no,
                      sarquan_question,
                     sarquan_answer,
                     sarquan_activity_date,
                     sarquan_user_id
    SELECT spriden_pidm,'1',
    '201090','1',
                     'Would you prefer September admission?',
                    DECODE (szcasup_sept_adm, 'Y', 'Yes', 'N', 'No'),sysdate,'recheverri'
               FROM saturn_midd.szcasup, saturn.spriden
              WHERE spriden_id = szcasup_common_appl_id
                AND spriden_ntyp_code = 'CAPP'
                 and spriden_pidm = 2287953
                AND (   szcasup_sept_adm IS NOT NULL
                     OR szcasup_feb_adm IS NOT NULL
                     OR szcasup_interview IS NOT NULL
                AND NOT EXISTS (
                       SELECT *
                         FROM saturn.sarquan
                        WHERE sarquan_pidm = spriden_pidm
                          AND spriden_ntyp_code = 'CAPP'
                          AND sarquan_term_code_entry = '201090');
                          Edited by: peace4all on Aug 13, 2009 5:35 AM

  • Table is mutating, trigger/function may not see it

    Hi,
    I have been trying to get a trigger to execute a stored procedure when an update is made to a row in a table.
    The procedure works when ran manually and the trigger compiles but when the trigger is fired I get a "table is mutating, trigger/function may not see it" error.
    Here's a bit more background:
    I have a product table where the cost of a product is calculate based on costs in other tables (e.g. cost of raw materials is in the suppliesrawmat table).
    I have written a procedure (called proc_costcalc) which takes in a productID and updates that product's cost in the product table.
    I want a trigger to do this for every affected product when a rawmaterial cost is changed.
    The code of my trigger is:
    CREATE OR REPLACE trigger trig_rawcostupdate
    AFTER INSERT OR UPDATE ON suppliesrawmat FOR EACH ROW
    DECLARE
         cursor c1 is
         SELECT p.prodid
         FROM process p,
              (SELECT s.processid
              FROM stage s,
                   (SELECT stageno
                   FROM stagerawmat
                   WHERE prodid = :new.prodid) subquery0
              WHERE s.stageno = subquery0.stageno) subquery1
         WHERE p.processid = subquery1.processid;
    BEGIN
         FOR tuple in c1
         LOOP
              proc_costcalc(tuple.prodid);
         END LOOP;
    END;
    The query for the cursor generates a list of productIDs which I need to run through the proc_costcalc procedure.
    Can anyone show me where I am going wrong? How can I fix this?
    Thanks
    Keith

    I'm afraid I'm still not getting this.
    Suppose I have 4 tables (product, madefrom, rawmat and suppliesrawmat).
    Product (productid, cost)
    Madefrom (productid, rawmatid)
    Rawmat (rawmatid)
    Suppliesrawmat (supplierid, rawmatid, cost)
    The cost of a product should be the sum cost of all rawmaterials it is made from where the cheapest supply cost of that material is used.
    What I want to do is update the cost of a product when the cost of a raw material used in its production changes.
    My earlier attempt was to have a procedure which when given a productid updates the price of that product. However, when trying to call this procedure from an update on the suppliesrawmat table I recieved the table is mutating error. I now understand why (thanks to everyone for that) but I still don't really know how to rectify the problem.
    How should I be doing this?
    Thanks again
    Keith

  • ORA-04091 table string.string is mutating, trigger/function may not see it

    When I am tending to delete something from my table I received this message.
    I defined a PL/SQL function reads data from that table. Is that meaning I could not modify anything in table once I have some PL/SQL defined on that? It sounds ridiculour. Or I missed some points?
    Anyone could help me out?
    Many thanks,
    Qiang

    In get_point_coordinates(point_id, layerid), it does not have any codes deleting thing from point_tab.
    Its functionality is to find out that specified point;
    put its coordinates into SDO_GEOMETRY object and return as function value.
    However, oracle does not allow me to delete any data from point table since then.It is saying that function (get_point_coordinates) can not know mutating tables.
    When I run delete task:
    delete from point$_view where point_id = 1;
    I got errors:
    ERROR at line 1:
    ORA-04091: table POINT$_TABLE is mutating, trigger/functio
    n may not see it
    ORA-06512: at "GET_POINT_COORDINATES", /* THIS LINE REPORS ERROR*/ Look at codes below.
    The following is code of function: GET_POINT_COORDINATES
    FUNCTION GET_POINT_COORDINATES(pPoint_ID IN NUMBER, player_ID IN NUMBER)
    RETURN MDSYS.SDO_GEOMETRY DETERMINISTIC IS
    PSRID NUMBER :=NULL:
    PLON NUMBER := NULL;
    PLAT NUMBER := NULL;
    CURSOR get_lonlat(ppoint_id IN NUMBER, player_id IN NUMBER) IS SELECT LON,LAT
    FROM POINT$_VIEW /* THIS LINE REPORS ERROR*/
    WHERE player_id = layer_id AND ppoint_id = point_id;
    BEGIN
    PSRID := 8265;
    OPEN get_lonlat(pPoint_ID,Player_ID);
    FETCH get_lonlat INTO PLON, PLAT;
    RETURN MDSYS.SDO_GEOMETRY(2001,PSRID,MDSYS.SDO_POINT_TYPE(PLON,PLAT,NULL),NULL ,NULL);
    END GET_POINT_GEOM;
    I guess it has nothing with foreign key. There is something wrong with this function.
    By the way, a spatail index is built on this function. Does this make any differences on this point?

  • ORA-04091: table CCS.T_PROCESSLOG is mutating, trigger/function may not see it

    I have a problem. Here is a trigger that I'm working with.
    CREATE OR REPLACE TRIGGER Trgedw_extract
    AFTER INSERT OR UPDATE OF completioncode ON CCS.t_processlog
    FOR EACH ROW
    WHEN ( (OLD.filename = 'ACCTINFO') AND (OLD.completioncode = 1) )
    BEGIN
    CCS.Edwextract;
    END;The t_processlog table has a field (processid) that is the primary key. However the processid wasn't setup as a sequence number directly through Oracle. It was set up as a sequence number through a trigger. (Don't ask...)
    The code for the procedure that the code above call is here.
    CREATE OR REPLACE PROCEDURE Edwextract AS
    Jobname: Edwextract
    Author: Adam Bolduc
    Date: 6/18/2001
    Purpose: To run the monthly jobs (ccs.populateedw92, ccs.populateedw54) to
    populate the t_edw table and export the data to a flat file on the system.
    This file will be sent to edw. Then drop and recreate the index on the t_edw table
    to access the data faster.
    EDW92 EXCEPTION;
    EDW54 EXCEPTION;
    PUTLINE_ERROR EXCEPTION;
    FILE_OPEN_ERROR EXCEPTION;
    FILE_CLOSE_ERROR EXCEPTION;
    DROP_INDEX_FLAG EXCEPTION;
    CREATE_INDEX_FLAG EXCEPTION;
    dPid ccs.t_processlog.PROCESSID%TYPE;
    szdata_rec CHAR(1436);
    outfile_name VARCHAR2(50) DEFAULT 'edw.txt';
    outfile_dir VARCHAR2(100) DEFAULT '/scratch/edw/';
    outfile_handle UTL_FILE.file_type;
    szSQLErrText VARCHAR2(250);
    iRetValue PLS_INTEGER;
    icursor_name INTEGER;
    irows_processed INTEGER;
    dtDateProcess ccs.t_processlog.PROCESSDATE%TYPE;
    CURSOR edw_extract_cur IS
    SELECT
    ccs.t_edw.RECORDIDENTIFIER&#0124; &#0124;
    ccs.t_edw.TSYSVERSIONINDICATOR&#0124; &#0124;
    ccs.t_edw.TS1CREDITRATING&#0124; &#0124;
    ccs.t_edw.TS1BILLINGTYPE&#0124; &#0124;
    ccs.t_edw.TS1PROCESSTYPE&#0124; &#0124;
    ccs.t_edw.TS1BANKNUMBER&#0124; &#0124;
    ccs.t_edw.TS1AGENTBANKNUMBER&#0124; &#0124;
    ccs.t_edw.PRODUCTCODE&#0124; &#0124;
    ccs.t_edw.CLIENTPRODUCTCODE&#0124; &#0124;
    ccs.t_edw.TRACKINGNUMBER&#0124; &#0124;
    ccs.edwaccountencrypt(ccs.t_edw.ACCOUNTNUMBER)&#0124; &#0124;
    ' '&#0124; &#0124;
    ccs.t_edw.NAMEPRIMARY&#0124; &#0124;
    ccs.t_edw.NAMECOAPP&#0124; &#0124;
    ccs.t_edw.ADDRESSLINE1&#0124; &#0124;
    ccs.t_edw.ADDRESSLINE2&#0124; &#0124;
    ccs.t_edw.CITY&#0124; &#0124;
    ccs.t_edw.STATEPROVINCECODE&#0124; &#0124;
    ccs.t_edw.ZIPCODE&#0124; &#0124;
    ccs.edwssnencrypt(ccs.t_edw.SSN)&#0124; &#0124;
    ccs.t_edw.HOMEPHONENUMBER&#0124; &#0124;
    ccs.t_edw.PHOTOCARDINDICATOR&#0124; &#0124;
    ccs.t_edw.ACCOUNTTYPE&#0124; &#0124;
    NVL(ccs.t_edw.InsuranceType , '000' )&#0124; &#0124;
    ccs.t_edw.ASSETPOOLNUMBER&#0124; &#0124;
    ccs.t_edw.STATEMENTHOLDCODE&#0124; &#0124;
    ccs.t_edw.BRANCHNUMBER&#0124; &#0124;
    ccs.t_edw.BANKRUPTCYPREDICTORSCORE&#0124; &#0124;
    ccs.t_edw.DATELASTBANKRUPTCYRESCORE&#0124; &#0124;
    NVL(ccs.t_edw.DATEOPEN,'0000000')&#0124; &#0124;
    ccs.t_edw.DATEEXPIRATION&#0124; &#0124;
    ccs.t_edw.DATECUSTOMERBIRTH&#0124; &#0124;
    ccs.t_edw.DATECLOSEDVOLUNTARY&#0124; &#0124;
    ccs.t_edw.DATECLOSEDINVOLUNTARY&#0124; &#0124;
    ccs.t_edw.DATELASTACTIVE&#0124; &#0124;
    ccs.t_edw.DATELASTPAYMENT&#0124; &#0124;
    ccs.t_edw.DATELASTPURCHASE&#0124; &#0124;
    ccs.t_edw.DATECHARGEOFF&#0124; &#0124;
    NVL(ccs.t_edw.DateLastStatement , '0000000' )&#0124; &#0124;
    ccs.t_edw.DATEHIGHESTBALANCELTD&#0124; &#0124;
    ccs.t_edw.DATELASTCREDITLIMITCHANGE&#0124; &#0124;
    ccs.t_edw.STATUSCLOSED&#0124; &#0124;
    ccs.t_edw.STATUSCREDITREVOKED&#0124; &#0124;
    ccs.t_edw.STATUSPASTDUE&#0124; &#0124;
    ccs.t_edw.STATUSCHARGEOFF&#0124; &#0124;
    NVL(ccs.t_edw.StatusSkipPayment , ' ' )&#0124; &#0124;
    ccs.t_edw.CHARGEOFFTYPE&#0124; &#0124;
    NVL(ccs.t_edw.MinimunPaymentDue , '000000000000000' )&#0124; &#0124;
    ccs.t_edw.CURRENTBALANCE&#0124; &#0124;
    NVL(ccs.t_edw.PreviousStatementBalance , '000000000000000' )&#0124; &#0124;
    ccs.t_edw.BALANCECHARGEDOFF&#0124; &#0124;
    ccs.t_edw.CURRENTCREDITLIMIT&#0124; &#0124;
    ccs.t_edw.ORIGINALCREDITLIMIT&#0124; &#0124;
    NVL(ccs.t_edw.BalancePastDueCycle , '000000000000000' )&#0124; &#0124;
    ccs.t_edw.HIGHESTBALANCELTD&#0124; &#0124;
    NVL(ccs.t_edw.AnnualFeeCharge , '000000000000000' )&#0124; &#0124;
    ccs.t_edw.AVAILABLEMONEY&#0124; &#0124;
    ccs.t_edw.NUMCREDITLIMITINCREASES&#0124; &#0124;
    ccs.t_edw.NUMCREDITLIMITDECREASES&#0124; &#0124;
    NVL(ccs.t_edw.APRPurchases , '000000' )&#0124; &#0124;
    NVL(ccs.t_edw.APRCash , '000000' )&#0124; &#0124;
    NVL(ccs.t_edw.APROldPurchases , '000000' )&#0124; &#0124;
    ccs.t_edw.APRBALTRANSFER1&#0124; &#0124;
    NVL(ccs.t_edw.APRPromoCash , '000000' )&#0124; &#0124;
    NVL(ccs.t_edw.APRPromoPurchases , '000000' )&#0124; &#0124;
    ccs.t_edw.APRBALTRANSFER2&#0124; &#0124;
    NVL(ccs.t_edw.RateTypePurchases , ' ' )&#0124; &#0124;
    NVL(ccs.t_edw.RateTypeCash , ' ' )&#0124; &#0124;
    ccs.t_edw.RATETYPEOLDPURCHASES&#0124; &#0124;
    ccs.t_edw.RATETYPEBALTRANSFER1&#0124; &#0124;
    ccs.t_edw.RATETYPEPROMOCASH&#0124; &#0124;
    ccs.t_edw.RATETYPEPROMOPURCHASES&#0124; &#0124;
    ccs.t_edw.RATETYPEBALTRANSFER2&#0124; &#0124;
    NVL(ccs.t_edw.ADBPurchases , '000000000000000' )&#0124; &#0124;
    NVL(ccs.t_edw.ADBCash , '000000000000000' )&#0124; &#0124;
    ccs.t_edw.ADBOLDPURCHASES&#0124; &#0124;
    ccs.t_edw.ADBBALTRANSFER1&#0124; &#0124;
    ccs.t_edw.ADBPROMOCASH&#0124; &#0124;
    ccs.t_edw.ADBPROMOPURCHASES&#0124; &#0124;
    ccs.t_edw.ADBBALTRANSFER2&#0124; &#0124;
    ccs.t_edw.ASSESSEDFEEANNUAL&#0124; &#0124;
    NVL(ccs.t_edw.AssessedFeeCash , '000000000000000' )&#0124; &#0124;
    NVL(ccs.t_edw.AssessedFeeFinanceCharges, '000000000000000' )&#0124; &#0124;
    NVL(ccs.t_edw.AssessedFeeInsurance , '000000000000000' )&#0124; &#0124;
    NVL(ccs.t_edw.AssessedFeeLate , '000000000000000' )&#0124; &#0124;
    NVL(ccs.t_edw.AssessedFeeOverlimit , '000000000000000' )&#0124; &#0124;
    ccs.t_edw.ASSESSEDFEERETURNEDCHECK&#0124; &#0124;
    NVL(ccs.t_edw.BilledTotalDollars , '000000000000000' )&#0124; &#0124;
    NVL(ccs.t_edw.BilledPurchases , '000000000000000' )&#0124; &#0124;
    NVL(ccs.t_edw.BilledCash , '000000000000000' )&#0124; &#0124;
    ccs.t_edw.BILLEDOLDPURCHASES&#0124; &#0124;
    ccs.t_edw.BILLEDBALTRANSFER1&#0124; &#0124;
    ccs.t_edw.BILLEDPROMOCASH&#0124; &#0124;
    ccs.t_edw.BILLEDPROMOPURCHASES&#0124; &#0124;
    ccs.t_edw.BILLEDBALTRANSFER2&#0124; &#0124;
    ccs.t_edw.BILLEDMISC&#0124; &#0124;
    NVL(ccs.t_edw.BilledFinanceCharges , '000000000000000' )&#0124; &#0124;
    NVL(ccs.t_edw.NewChargesPurchases , '000000000000000' )&#0124; &#0124;
    NVL(ccs.t_edw.NewChargesCashAdvances , '000000000000000' )&#0124; &#0124;
    ccs.t_edw.NEWCHARGESCONVCHECK&#0124; &#0124;
    NVL(ccs.t_edw.NewChargesATM , '000000000000000' )&#0124; &#0124;
    ccs.t_edw.NEWCHARGESBALXFERPURCH&#0124; &#0124;
    ccs.t_edw.NEWCHARGESBALXFERCHECK&#0124; &#0124;
    NVL(ccs.t_edw.NewChargesFinanceCharges , '000000000000000' )&#0124; &#0124;
    NVL(ccs.t_edw.NewChargesCashFees , '000000000000000' )&#0124; &#0124;
    NVL(ccs.t_edw.NewChargesInsuranceFees , '000000000000000' )&#0124; &#0124;
    ccs.t_edw.NEWCHARGESRETURNEDCHECKS&#0124; &#0124;
    NVL(ccs.t_edw.NewChargesOverlimitFees , '000000000000000' )&#0124; &#0124;
    NVL(ccs.t_edw.NewChargesPurchaseFC , '000000000000000' )&#0124; &#0124;
    NVL(ccs.t_edw.NewChargesCashFC , '000000000000000' )&#0124; &#0124;
    NVL(ccs.t_edw.NewChargesAnnualFees , '000000000000000' )&#0124; &#0124;
    NVL(ccs.t_edw.NewChargesLateFees , '000000000000000' )&#0124; &#0124;
    NVL(ccs.t_edw.AmountOfPayments , '000000000000000' )&#0124; &#0124;
    NVL(ccs.t_edw.AmountOfCredits , '000000000000000' )&#0124; &#0124;
    NVL(ccs.t_edw.NumberOfPurchases , '00000' )&#0124; &#0124;
    NVL(ccs.t_edw.NumberOfCashAdvances , '00000' )&#0124; &#0124;
    ccs.t_edw.TS1COMPANYNUMBER&#0124; &#0124;
    ccs.t_edw.COUNTRYCODE&#0124; &#0124;
    ' '&#0124; &#0124; -- MCIF Close code
    ccs.t_edw.FILENUMBER&#0124; &#0124;
    ' '&#0124; &#0124;
    ' '&#0124; &#0124;
    '00000'&#0124; &#0124;
    ' '&#0124; &#0124;
    '000000000000000'&#0124; &#0124;
    '0000000'&#0124; &#0124;
    '00000'&#0124; &#0124;
    ' '&#0124; &#0124;
    '000000000000000'&#0124; &#0124;
    ' '&#0124; &#0124;
    ' '&#0124; &#0124;
    ' '&#0124; &#0124;
    ' '&#0124; &#0124;
    ' '&#0124; &#0124;
    ' '&#0124; &#0124;
    ' '&#0124; &#0124;
    ' '&#0124; &#0124;
    DECODE(ccs.t_account.prodind, 1, ' ', 'F')
    FROM
    ccs.t_edw,
    ccs.t_account
    WHERE ccs.t_edw.accountid = ccs.t_account.accountid
    AND ccs.t_account.dateopen = to_date(ccs.t_edw.DATEOPEN,'yyyyddd')
    AND ccs.t_account.dateopen < (add_months(dtDateProcess,1)-1);
    BEGIN
    SELECT max(processdate)
    INTO dtDateProcess
    FROM ccs.t_processlog
    WHERE filename = 'ACCTINFO';
    -- Create a log entry in the t_processlog
    INSERT INTO ccs.t_processlog
    (filename,processdate,completioncode)
    VALUES
    ('EDWEXTRACT',dtDateProcess,9);
    SELECT max(processid)
    INTO dPid
    FROM ccs.t_processlog
    WHERE filename = 'EDWEXTRACT'
    AND processdate = dtDateProcess;
    iRetValue := CCS.StartPID(dPid, 0, 0);
    ccs.populateedw92(1, dtDateProcess);
    IF (SQLCODE != 0) THEN
    iRetValue := CCS.UpdatePIDDesc(dPid, 1, 99, 'ccs.populateedw92 failed! See t_exception for error.',0);
    RAISE EDW92;
    END IF;
    ccs.populateedw54(2, dtDateProcess);
    IF (SQLCODE != 0) THEN
    iRetValue := CCS.UpdatePIDDesc(dPid, 1, 99, 'ccs.populateedw54 failed! See t_exception for error.',0);
    RAISE EDW54;
    END IF;
    OPEN edw_extract_cur;
    -- Caution: UTL_FILE.FOPEN using w option! Will overwrite existing file!
    outfile_handle := UTL_FILE.FOPEN(outfile_dir,outfile_name,'w',1437);
    IF (SQLCODE != 0) THEN
    iRetValue := CCS.UpdatePIDDesc(dPid, 1, 99, 'Problem creating data file! See t_exception for error.',0);
    RAISE FILE_OPEN_ERROR;
    END IF;
    LOOP
    FETCH edw_extract_cur INTO szdata_rec;
    EXIT WHEN edw_extract_cur%NOTFOUND;
    UTL_FILE.PUT_LINE(outfile_handle,szdata_rec);
    IF (SQLCODE != 0) THEN
    iRetValue := CCS.UpdatePIDDesc(dPid, 1, 99, 'Problem creating data file! See t_exception for error.',0);
    RAISE PUTLINE_ERROR;
    END IF;
    END LOOP;
    -- update t_processlog with status of 1 for dPid
    UTL_FILE.FCLOSE (outfile_handle);
    IF (SQLCODE != 0) THEN
    iRetValue := CCS.UpdatePIDDesc(dPid, 1, 99, 'Problem closing data file! See t_exception for error.',0);
    RAISE FILE_CLOSE_ERROR;
    END IF;
    -- Drop index on t_edw table
    icursor_name := sys.dbms_sql.open_cursor;
    sys.dbms_sql.parse(icursor_name,'DROP INDEX ccs.i_t_edw_accountid ', sys.dbms_sql.v7);
    irows_processed := sys.dbms_sql.execute(icursor_name);
    sys.dbms_sql.close_cursor(icursor_name);
    IF (sqlcode != 0) THEN
    RAISE DROP_INDEX_FLAG;
    ELSE
    COMMIT;
    END IF;
    -- Recreate index on t_edw table
    icursor_name := sys.dbms_sql.open_cursor;
    sys.dbms_sql.parse(icursor_name,'CREATE INDEX ccs.i_t_edw_accountid ON ccs.t_edw (accountid) tablespace tsindex storage (initial 30m next 30m pctincrease 0) parallel(degree 5) nologging', sys.dbms_sql.v7);
    irows_processed := sys.dbms_sql.execute(icursor_name);
    sys.dbms_sql.close_cursor(icursor_name);
    IF (sqlcode != 0) THEN
    RAISE CREATE_INDEX_FLAG;
    ELSE
    iRetValue := CCS.UpdatePIDDesc(dPid, 1, 1, 'EDWEXTRACT Completed successfully.',0);
    COMMIT;
    END IF;
    EXCEPTION WHEN EDW54 THEN
    szSQLErrText := SUBSTR(SQLERRM,1,250);
    iRetValue := ccs.ExceptionWrite(dPid,szSQLErrText,'The populateedw54 failed! Contact support personnel.');
    WHEN EDW92 THEN
    szSQLErrText := SUBSTR(SQLERRM,1,250);
    iRetValue := ccs.ExceptionWrite(dPid,szSQLErrText,'The populateedw92 failed! Contact support personnel.');
    WHEN DROP_INDEX_FLAG THEN
    szSQLErrText := SUBSTR(SQLERRM,1,250);
    iRetValue := ccs.ExceptionWrite(dPid,szSQLErrText,'Failed to drop index on t_edw table! Contact support personnel.');
    WHEN CREATE_INDEX_FLAG THEN
    szSQLErrText := SUBSTR(SQLERRM,1,250);
    iRetValue := ccs.ExceptionWrite(dPid,szSQLErrText,'Failed to create index on t_edw table! Contact support personnel.');
    WHEN NO_DATA_FOUND THEN
    szSQLErrText := SUBSTR(SQLERRM,1,250);
    iRetValue := ccs.ExceptionWrite(dPid,szSQLErrText,'No data found! Contact support personnel.');
    WHEN FILE_CLOSE_ERROR THEN
    szSQLErrText := SUBSTR(SQLERRM,1,250);
    iRetValue := ccs.ExceptionWrite(dPid,szSQLErrText,'Unable to close data file! Contact support personnel.');
    WHEN PUTLINE_ERROR THEN
    szSQLErrText := SUBSTR(SQLERRM,1,250);
    iRetValue := ccs.ExceptionWrite(dPid,szSQLE   rrText,'Failed to write szdata_rec to file! Contact support personnel.');
    WHEN FILE_OPEN_ERROR THEN
    szSQLErrText := SUBSTR(SQLERRM,1,250);
    iRetValue := ccs.ExceptionWrite(dPid,szSQLErrText,'Failed to open data file! Contact support personnel.');
    WHEN UTL_FILE.INVALID_PATH THEN
    szSQLErrText := SUBSTR(SQLERRM,1,250);
    iRetValue := ccs.ExceptionWrite(dPid,szSQLErrText,'Invalid path! Contact support personnel.');
    WHEN UTL_FILE.INVALID_MODE THEN
    szSQLErrText := SUBSTR(SQLERRM,1,250);
    iRetValue := ccs.ExceptionWrite(dPid,szSQLErrText,'Invalid mode! Contact support personnel.');
    WHEN UTL_FILE.INVALID_FILEHANDLE THEN
    szSQLErrText := SUBSTR(SQLERRM,1,250);
    iRetValue := ccs.ExceptionWrite(dPid,szSQLErrText,'Bad file handle! Contact support personnel.');
    WHEN UTL_FILE.INVALID_OPERATION THEN
    szSQLErrText := SUBSTR(SQLERRM,1,250);
    iRetValue := ccs.ExceptionWrite(dPid,szSQLErrText,'Invalid operation! Contact support personnel.');
    WHEN UTL_FILE.WRITE_ERROR THEN
    szSQLErrText := SUBSTR(SQLERRM,1,250);
    iRetValue := ccs.ExceptionWrite(dPid,szSQLErrText,'Unable to write to file, ERROR! Contact support personnel.');
    WHEN UTL_FILE.INTERNAL_ERROR THEN
    szSQLErrText := SUBSTR(SQLERRM,1,250);
    iRetValue := ccs.ExceptionWrite(dPid,szSQLErrText,'Utl_file internal error! Contact support personnel.');
    WHEN OTHERS THEN
    szSQLErrText := SUBSTR(SQLERRM,1,250);
    iRetValue := ccs.ExceptionWrite(dPid,szSQLErrText,'EDWEXTRACT failed due to unknown reason! Contact support personnel.');
    END;
    /I guess my confusion is how can I put a trigger on the t_processlog table to start a job when another finishes, and still have the job called make an entry into the t_processlog? I looked at the code for suggested work around, but I'm a little confused as to what is going on. Can anyone give me an idea for what to do in the situation? Thanks.
    Adam Bolduc
    null

    I didn't see your coding but i think you are selecting the same table through the procedure, on which you have written the db trigger.
    In that case it will alway gives you mutating error.
    Sanjeev

  • Table is mutating, trigger/function may not

    hi
    while executing this:
    SQL> insert into LIB_ACCESSION_LOG select * from LIB_ACCESSION_LOG11;
    insert into LIB_ACCESSION_LOG select * from LIB_ACCESSION_LOG11
    ERROR at line 1:
    ORA-04091: table QA.LIB_ACCESSION_LOG is mutating, trigger/function may not
    see it
    ORA-06512: at "QA.TRG_ACCESSION_LOG", line 2
    ORA-04088: error during execution of trigger 'QA.TRG_ACCESSION_LOG'
    how can i do this insert and resolve this error. should i switch off the constraints? and what will happen when i switch on the constraints?

    Hi,
    what is the contents for trigger QA.TRG_ACCESSION_LOG?
    cheers

Maybe you are looking for