URGENT : Trigger with Mutating Error

Hi,
I'm trying to write a trigger on a Table ROOM_BLOCK to update a value in table ROOM_OOI_OOS.
As given below, which works perfectly.
BEGIN
IF INSERTING THEN
IF NVL(:NEW.ROOM_OOI_OOS_ID,0) <> 0 THEN
UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)+1
WHERE ROOM_OOI_OOS_ID = :NEW.ROOM_OOI_OOS_ID;
END IF;
ELSIF UPDATING THEN
IF NVL(:OLD.ROOM_OOI_OOS_ID,0) <> 0 THEN
UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)-1
WHERE ROOM_OOI_OOS_ID = :OLD.ROOM_OOI_OOS_ID;
END IF;
IF NVL(:NEW.ROOM_OOI_OOS_ID,0) <> 0 THEN
UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)+1
WHERE ROOM_OOI_OOS_ID = :NEW.ROOM_OOI_OOS_ID;
END IF;
ELSE
IF NVL(:OLD.ROOM_OOI_OOS_ID,0) <> 0 THEN
UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)-1
WHERE ROOM_OOI_OOS_ID = :OLD.ROOM_OOI_OOS_ID;
END IF;
END IF;
END;
But when I add a select statement. the trigger seems to fail with a mutating error ORA-04091
and Error at Line which executes the statement immidiate ORA-04088.
DECLARE
stmt VARCHAR2(500);
vcount INTEGER;
BEGIN
IF INSERTING THEN
--INSERT INTO SHRUTI_TEST (DESCR) VALUES ('Inserting');
IF NVL(:NEW.ROOM_OOI_OOS_ID,0) <> 0 THEN
stmt := 'Select count(*) from ROOM_BLOCK ' ||
' WHERE ROOM_OOI_OOS_ID = ' || :NEW.ROOM_OOI_OOS_ID ||
' AND ROOM_NO = ''' || :NEW.ROOM_NO || ''' ';
EXECUTE IMMEDIATE stmt INTO vcount;
IF vcount = 1 THEN
UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)+1
WHERE ROOM_OOI_OOS_ID = :NEW.ROOM_OOI_OOS_ID;
END IF;
END IF;
ELSIF UPDATING THEN
IF NVL(:OLD.ROOM_OOI_OOS_ID,0) <> 0 THEN
UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)-1
WHERE ROOM_OOI_OOS_ID = :OLD.ROOM_OOI_OOS_ID;
END IF;
IF NVL(:NEW.ROOM_OOI_OOS_ID,0) <> 0 THEN
UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)+1
WHERE ROOM_OOI_OOS_ID = :NEW.ROOM_OOI_OOS_ID;
END IF;
ELSE
IF NVL(:OLD.ROOM_OOI_OOS_ID,0) <> 0 THEN
UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)-1
WHERE ROOM_OOI_OOS_ID = :OLD.ROOM_OOI_OOS_ID;
END IF;
END IF;
END;
Please tell me how to solve this problem...
Regards
Mike.

Thank you for your reply to my posting.
I researched and used your recommendation. I was
wondering if you can help me resolve the following two
problems.
Table kassa1 has NAME and AGE columns. Table Kassa2
has one column Age.
I have created the following trigger. It keeps
raising a ORA-06519 : Active autonomous transaction
detected and rolled back error.
Create or replace trigger Name_Age_Row after insert or
update on Kassa1
For each row
Declare
Total_Age VARCHAR(8);
PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
     Select SUM(Age) into Total_Age from Kassa1;
     insert into kassa2 values(Total_aAge);
End;     
The following trigger also generates ORA-00036:
Maximum number of recursive SQL levels(50) exceeded
error.
Create or replace trigger Name_Age_Row after insert or
update on Kassa1
For each row
Declare
PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
     insert into kassa1 values('newname', 'newage');
End;     

Similar Messages

  • Help with Mutating Error / Trigger / APEX_MAIL.SEND

    Hello:
    I am trying to get the apex_mail.send function working when a user submits a new record. I've taken the code from the canned Issue Tracker application code and tried to retrofit it to my tables. However I keep receiving a mutating error on line 11 (line 11 bolded below):
    -- Create a trigger that will send notification after
    -- the submission of each new idea on the IDEAS table.
    create or replace trigger IDEAS_EMAIL
    AFTER
    insert or update on IDEAS
    for each row
    begin
    IF (INSERTING AND :new.manager_name IS NOT NULL)
    OR
    (UPDATING AND (:old.manager_name IS NULL OR :new.manager_name != :old.manager_name) AND :new.manager_name IS NOT NULL) THEN
    FOR c1 IN
    (SELECT fname, lname, email
    FROM ideas_users
    WHERE fname||' '||lname = :new.manager_name)
    LOOP
    IF c1.email IS NOT NULL THEN
    FOR c2 IN
    (SELECT MANAGER_NAME, FULL_TEXT, SUMMARY, ID, SUBMITTED_BY, SUB_DATE
    FROM IDEAS
    WHERE ID = :new.ID)
    LOOP
    APEX_MAIL.SEND(
    p_to => c1.email,
    p_from => c1.email,
    p_body =>
    'This is a test message. ' ||chr(10)||
    p_subj => 'test email subject');
    END LOOP;
    END IF;
    END LOOP;
    END IF;
    end;
    I've also tried setting the following line to the primary key field in the user table and inserting that value into the main table but I still get the same error message.
    WHERE fname||' '||lname = :new.manager_name)
    Thanks in advance for any help.

    Let me get this straight..
    You are inserting a row into a table, and when you insert the row, you are going to send an e-mail t o the manager who owns this row. In the data you are inserting, is the e-mail address of the manager, right?
    David has provided the answer for you.. Use the :NEW.Email value instead of creating a cursor and all that.. Unless you have a need to e-mail multiple people of the record insert..
    Thank you,
    Tony Miller
    Webster, TX
    On the road of life...There are 'windshields', and there are 'bugs'
    (splat!)
    "Squeegees Wanted"

  • This trigger giving mutation error? any body can tell why?

    Hi All,
    Could any body tell me where is the problem in my trigger.
    my tables are.
    1) EMP :- emp_id,emp_movement_status
    2) EMPLOYEES_DAILY_MOVEMENT :- emp_id,transaction_time,transaction_remarks.
    if i delete a entry from transactions_table, it has to take latest remarks from the maximum record after deletion of the record, then update EMP table accordingly.
    trigger is:-
    CREATE OR REPLACE TRIGGER change_employee_status AFTER INSERT OR UPDATE OR DELETE ON
    employees_daily_movement FOR EACH ROW
    DECLARE
    local_remarks VARCHAR2(50);
    BEGIN
    IF DELETING THEN
    SELECT transaction_remarks INTO local_remarks FROM employees_daily_movement WHERE
         transaction_id = (SELECT MAX(transaction_id) FROM employees_daily_movement WHERE
         emp_id = :old.emp_id );
    /* here im expecting to take the TRANSACTION_REMARKS column value from employees_daily_movement after deleting the record which i wanted */
    UPDATE emp SET emp_movement_status = local_remarks WHERE emp_id = :old.emp_id;
    END IF;
    END;
    Thanks in advance

    Hi Mr Rao,
    You can handle muttating erros with following
    1. Database version is oracle 9i and above, you can over come this problem for ever by using pragma autonomous_transaction.
    2. Another way is, if you database version earlier to 9i then you can re-pharase this trigger by writting statement level trigger instead row level.
    Cheers!!
    Mahesh Ragineni

  • Help with mutating trigger

    Hi all,
    I have a trigger shown below is gives me the mutating error.
    The error is to do with the select from the payments table (which it does not allow cos of the mutating effect).
    Can anyone give me some ideas on how I can resolve this?
    Thank you very much
    create or replace
    TRIGGER CHECK_INVOICE_PAID_IN_FULL AFTER
    UPDATE OF "PAYMENT_STATUS" ON "PAYMENTS" FOR EACH ROW
    DECLARE
    -- check if all the payments for that invoice have been received (completed)
    -- if they are complete then sum all the payments for that invoice and compare to gross value on invoices
    v_invoice_amount NUMBER;
    v_gross_amount NUMBER;
    thisproc CONSTANT VARCHAR2(80) := 'trap_errmesg for mco_transfer_status';
    v_value VARCHAR2(150);
    BEGIN
    -- Changed as requested by nicola on 12/09/05 IF :NEW.PAYMENT_COMPLETE is not null
    IF :NEW.PAYMENT_STATUS='C' AND :NEW.PAYMENT_STATUS <> :OLD.PAYMENT_STATUS
    THEN
    -- We will sum all the payments for that invoice that have a value in payment_complete
    SELECT NVL(SUM(amount),0) INTO v_invoice_amount FROM payments WHERE payment_complete IS NOT NULL AND invoice_id=:NEW.INVOICE_ID;
    -- We will also get the gross amount for the invoice to compare to the sum of the payments
    SELECT NVL(gross,0) INTO v_gross_amount FROM invoices WHERE
    invoice_id = :NEW.INVOICE_ID ;
    END IF;
    IF v_invoice_amount = v_gross_amount
    THEN
    UPDATE invoices SET paid_date=SYSDATE;
    END IF;
    END CHECK_INVOICE_PAID_IN_FULL;
    /

    Hi Anwar,
    Thanks for this.
    Can you please help me out here
    I did the bit with creating a temporay table to hold the invoice_ids and then created a procedure that will be fired by the trigger, however because of the clause
    IF :NEW.PAYMENT_STATUS='C' AND :NEW.PAYMENT_STATUS <> :OLD.PAYMENT_STATUS
    I cant use a statement level trigger for this procedure and when i use the row level trigger i get the mutating error.
    here is what i have got so far.
    A temporary table which holds the invoice_ids (this is called payments_temp)
    I then created a trigger as below which populates this temp table
    TRIGGER insert_payments_temp BEFORE
    UPDATE OF "PAYMENT_STATUS" ON "PAYMENTS" FOR EACH ROW
    DECLARE
    -- check if all the payments for that invoice have been received (completed)
    -- if they are complete then sum all the payments for that invoice and compare to gross value on invoices
    v_invoice_amount NUMBER;
    v_gross_amount NUMBER;
    thisproc CONSTANT VARCHAR2(80) := 'trap_errmesg for mco_transfer_status';
    v_value VARCHAR2(150);
    BEGIN
    INSERT INTO payments_temp
    VALUES (:NEW.invoice_id);
    END insert_payments_temp;
    Then I created a procedure below which will do the update
    PROCEDURE "CHECK_INVOICE_PAID_IN_FULL_PRO" IS
    -- check if all the payments for that invoice have been received (completed)
    -- if they are complete then sum all the payments for that invoice and compare to gross value on invoices
    v_invoice_amount NUMBER(20);
    v_gross_amount NUMBER;
    thisproc CONSTANT VARCHAR2(80) := 'trap_errmesg for mco_transfer_status';
    v_value VARCHAR2(150);
    BEGIN
    -- We will sum all the payments for that invoice that have a value in payment_complete
    --select sum(amount) into v_invoice_amount from payments where payment_complete is not null and invoice_id=:NEW.INVOICE_ID;
    FOR x IN (SELECT invoice_id FROM payments_temp) LOOP
    SELECT NVL(SUM(amount),0) INTO v_invoice_amount FROM payments
    WHERE payment_complete IS NOT NULL AND invoice_id=X.INVOICE_ID;
    SELECT NVL(gross,0) INTO v_gross_amount FROM INVOICES WHERE
    invoice_id = X.INVOICE_ID ;
    END LOOP;
    -- We will also get the gross amount for the invoice to compare to the sum of the payments
    IF v_invoice_amount = v_gross_amount
    THEN
    UPDATE INVOICES SET paid_date=SYSDATE;
    COMMIT;
    END IF;
    END CHECK_INVOICE_PAID_IN_FULL_PRO;
    Then finally the update trigger itself below
    TRIGGER "NICKC"."CHECK_INVOICE_PAID_IN_FULL" AFTER
    UPDATE OF "PAYMENT_STATUS" ON "NICKC"."PAYMENTS" FOR EACH ROW
    DECLARE
    -- check if all the payments for that invoice have been received (completed)
    -- if they are complete then sum all the payments for that invoice and compare to gross value on invoices
    v_invoice_amount NUMBER;
    v_gross_amount NUMBER;
    thisproc CONSTANT VARCHAR2(80) := 'trap_errmesg for mco_transfer_status';
    v_value VARCHAR2(150);
    BEGIN
    -- Changed as requested by nicola on 12/09/05 IF :NEW.PAYMENT_COMPLETE is not null
    IF :NEW.PAYMENT_STATUS='C' AND :NEW.PAYMENT_STATUS <> :OLD.PAYMENT_STATUS
    THEN
    CHECK_INVOICE_PAID_IN_FULL_PRO;
    END IF;
    END CHECK_INVOICE_PAID_IN_FULL;
    However i still get the mutating error message and when i try to create a statemtnet level trigger i get the message say cannot use :NEW and :OLD values here.
    Please help

  • Trigger in mutation - Update another rows in the same table with a trigger

    Hi ,
    I try to do a before update trigger on a table , but the trigger is in mutation. I understand why it do that but my question is :
    How can I update other rows in the same table when a UPDATE is made on my table??????
    Here is my trigger :
    CREATE OR REPLACE TRIGGER GDE_COMPS_BRU_5 BEFORE
    UPDATE OF DEPARTEMENT--, DISCIPLINE, DEG_DEMANDE, CE_ETAB
    ON GDEM.COMPOSITION_SUBV
    FOR EACH ROW
    Organisme : FQRNT-FQRSC
    Date de création : 14-07-2011
    Date de modification :
    Modifié par :
    Auteur : Johanne Plamondon
    Description : Ce déclencheur s'executera lors de la modification
    du responsable dans la table COMPOSITION_SUBV
    DECLARE
    V_OSUSER V$SESSION.OSUSER%TYPE;
    V_PROGRAM V$SESSION.PROGRAM%TYPE;
    V_TERMINAL V$SESSION.TERMINAL%TYPE;
    V_MACHINE V$SESSION.MACHINE%TYPE;
    V_MODULE V$SESSION.MODULE%TYPE;
    V_LOGON_TIME V$SESSION.LOGON_TIME%TYPE;
    V_AUDIT_ID NUMBER;
    vSEQ NUMBER;
    i NUMBER;
    vID DEMANDE.ID%TYPE;
    BEGIN
    begin
    SELECT OSUSER, PROGRAM, TERMINAL,MACHINE,MODULE, LOGON_TIME
    INTO V_OSUSER,V_PROGRAM,V_TERMINAL,V_MACHINE,
    V_MODULE,V_LOGON_TIME
    FROM V$SESSION
    WHERE TYPE = 'USER'
    AND USERNAME = USER
    AND LAST_CALL_ET IN (0,1)
    AND ROWNUM < 2;
    exception when others then null; end;
    IF NVL(:NEW.SC_PART,' ') = 'CHC' THEN
    SELECT COUNT(*)
    INTO i
    FROM DEMANDE
    WHERE DEM_REF = :NEW.DEM_ID
    AND PER_NIP = :NEW.PER_NIP;
    IF i = 1 THEN
    SELECT ID
    INTO vID
    FROM DEMANDE
    WHERE DEM_REF = :NEW.DEM_ID
    AND PER_NIP = :NEW.PER_NIP;
    UPDATE COMPOSITION_SUBV
    SET --CE_ETAB     = :NEW.CE_ETAB,
    --DISCIPLINE  = :NEW.DISCIPLINE,
    DEPARTEMENT = :NEW.DEPARTEMENT,
    --DEG_DEMANDE = :NEW.DEG_DEMANDE,
    DATE_MODIF = SYSDATE,
    USER_MODIF = V_OSUSER
    WHERE DEM_ID = vID
    AND PER_NIP = :NEW.PER_NIP
    AND ANNEE = :NEW.ANNEE;
    END IF;
    END IF;
    /*EXCEPTION
    WHEN OTHERS THEN
    NULL;*/
    END;

    A standard disclaimer, the mutating trigger error is telling you that you really, really, really don't want to be doing this. It generally indicates a major data model problem when you find yourself in a situation where the data in one row of a table depends on the data in another row of that same table. In the vast majority of cases, you're far better off fixing the data model than in working around the problem.
    If you are absolutely sure that you cannot fix the data model and must work around the problem, you'll need
    - A package with a collection (or global temporary table) to store the keys that are modified
    - A before statement trigger that initializes the collection
    - A row-level trigger that adds the keys that were updated to the collection
    - An after statement trigger that iterates over the data in the collection and updates whatever rows need to be updated.
    If you're on 11g, this can be simplified somewhat by using a compound trigger with separate before statement, row-level, and after statement sections.
    Obviously, though, this is a substantial increase in complexity over the single trigger you have here. That's one of the reasons that it's generally a bad idea to work around mutating table exceptions.
    Justin

  • Mutating error in trigger

    Hi ,ihave created this trigger.its showing the mutating error as its selecting and updating the same table.So hw can we modify thsi trigger so that it worksd properly.
    CREATE OR REPLACE TRIGGER resolutionimpact
    AFTER INSERT OR UPDATE
    ON PROBLEMS
    REFERENCING NEW AS NEW OLD AS OLD
    FOR EACH ROW
    DECLARE
    newcause VARCHAR2(100);
    oldcause VARCHAR2(10);
    BEGIN
    oldcause:=:OLD.PROM_NCCCAUSE;
    newcause:=:NEW.PROM_NCCCAUSE;
    IF newcause='100' THEN
    UPDATE PROBLEMS SET PROM_IMPACT='CA_TCL FLP reset';
    --PROM_IMPACT='CA_TCL FLP reset';
    END IF;
    END;

    No actually I am udating single row.Actually the value is being entered from the oracle form from front end and no matter whatever value we enter for prom_impact from front end it should overwrite that value with fixed value when we press the save button .Also we cannot do anything at form level as we have fmx and nt the fmb.So have to do it through trigger only.Also there is another trigger running on same table which fetches the value from problem table and inserts it into another table.So what can be done to solve the issue

  • Master/Details tables with CASCADE delete giving "table mutating" error

    Hi,
    I have two tables in a master/details configuration (table 1 is "master", table 2 is "details").
    The details has a FK contraint relation to the master with a CASCADE delete (so when the master is deleted, all associated details are deleted).
    The master table has a column "last_updated_datetime" which is updated by a master table update trigger whenever most (excluding the last_updated_datetime column) columns are updated.
    The details table has an update trigger which also updates the master table's last_updated_datetime column (whenever a detail row is changed).
    The details table also has a delete trigger which also updated the master table's last_updated_datetime column (whenever a detail row is deleted).
    The problem I have is: When the master record is deleted, which cascade deletes the details record(s), the delete trigger on the details table throws a "table is mutating" error.
    I understand that the "mutating" error is "correct" because the master record is being deleted.
    But is there some way I can get around this problem (for example, having the details table delete trigger not update the master table last_updated_datetime) when it's this cascade delete?
    Thanks for your help!

    create table master (
      id number primary key,
      changed date not null
    create table detail (
      id number primary key,
      master_id references master (id) on delete cascade
    create or replace package pkg is
      master_deleted boolean := false;
    end;
    create or replace trigger bds_master
      before delete on master
    begin
      pkg.master_deleted := true;
    end;
    create or replace trigger ads_master
      after delete on master
    begin
      pkg.master_deleted := false;
    end;
    create or replace trigger adr_detail
      after delete on detail
      for each row
    begin
    if not pkg.master_deleted then
        update master
           set changed = sysdate
         where id = :old.master_id;
      end if;
    end;
    insert into master values (1, sysdate - 10);
    insert into detail values (11, 1);
    insert into detail values (12, 1);
    insert into master values (2, sysdate - 10);
    insert into detail values (21, 2);
    insert into detail values (22, 2);
    insert into master values (3, sysdate - 10);
    insert into detail values (31, 3);
    insert into detail values (32, 3);
    commit;
    select * from master order by id;
            ID CHANGED                                                             
             1 01.09.08                                                            
             2 01.09.08                                                            
             3 01.09.08                                                            
    select * from detail order by id;
            ID  MASTER_ID                                                          
            11          1                                                          
            12          1                                                          
            21          2                                                          
            22          2                                                          
            31          3                                                          
            32          3                                                          
    delete detail where id = 21;
    select * from master order by id;
            ID CHANGED                                                             
             1 01.09.08                                                            
             2 11.09.08
             3 01.09.08                                                            
    select * from detail order by id;
            ID  MASTER_ID                                                          
            11          1                                                          
            12          1                                                          
            22          2                                                          
            31          3                                                          
            32          3                                                          
    delete master where id in (1, 2);
    select * from master order by id;
            ID CHANGED                                                             
             3 01.09.08                                                            
    select * from detail order by id;
            ID  MASTER_ID                                                          
            31          3                                                          
            32          3                                                           Regards,
    Zlatko
    Edited by: Zlatko Sirotic on Sep 11, 2008 11:15 PM
    This is disaster - ten attempts to format code!

  • Mutating Error problem using audit trigger for UPDATE

    I need to add 4 columns to all of my tables named:
    INSERT_BY
    INSERT_DATA
    UPDATE_BY
    UPDATE_DATE
    I intend these to act as "inserted" and "last updated" audit trails within the table, as opposed to creating a new table and storing the audit information there. The insert columns appear to be easy, as I can just use a DEFAULT clause within the definition of the table. However when I attempted to write a (my first) trigger then I run into problems with mutating tables. Presumebly because I am attempting to change the table while the trigger is referencing it.
    create or replace trigger test_audit
    after update on dictionary
    begin
    update dictionary
    set update_by = user, update_date = sysdate
    where entity_id = :old.entity_id;
    end;
    I thought I could maybe get around this by calling a procedure from inside the trigger. Something like:
    create or replace procedure test_audit(vColumn in varchar2, vData in varchar2, vTable in varchar2) is
    -- vTable is table name
    -- vColumn is PK of table
    -- vData is value of PK in current row
    begin
    update vTable
    set update_by = user, update_date = sysdate
    where vColumn = vData;
    commit;
    end test_audit;
    However I cannot use variable for table names. Will this mean I have to create a procedure for each table/trigger? Is there a way to reference the table name as a variable and keep this a generic procedure? Or is there an easier way to record the auditing UPDATE information for each changed row within the original table?
    Many thanks in advance......

    Will
    this mean I have to create a procedure for each
    table/trigger? I think you've answered that question already.
    Is there a way to reference the table
    name as a variable and keep this a generic procedure?Not that I'm aware of.
    Or is there an easier way to record the auditing
    UPDATE information for each changed row within the
    original table?Well, there's the AUDIT feature.
    C.

  • Mutating error in my trigger code

    Hi,
    Could anyone please help me out to fix the mutating error:
    I have 2 tables z_errorpayment and z_errorcorrected.
    If the status=2 in z_errorpayment table then a row has to be inserted in z_errorcorrected table and the same row has to be deleted from the 1st table i.e z_errorpayment.As it is retriving from the same table and deleting the same table am getting mutating error.
    Below is the code.
    CREATE OR REPLACE TRIGGER row_trigger
    AFTER UPDATE
    ON z_errorpayment
    FOR EACH ROW
    WHEN (NEW.status = 2)
    BEGIN
    INSERT INTO z_errorcorrected
    (mtnl_error_payment_id, file_name, entry_date,
    centre_code, service_code, instrument_flag,
    instrument_no, subs_no, instrument_dt,
    payment_mode, payment_dt, surchrg,
    telephone_no, cheque_number, cheque_dt,
    bank_code, pay_amount, receipt_no,
    terminal_id, crtn_by, crtn_dt, remarks,
    status, external_trans_id, transfer_date,
    gl_uploaded_ind_code, task_queue_id,
    user_name, old_payment_id, new_payment_id,
    payment_type
    VALUES (:NEW.mtnl_error_payment_id, :NEW.file_name, :NEW.entry_date,
    :NEW.centre_code, :NEW.service_code, :NEW.instrument_flag,
    :NEW.instrument_no, :NEW.subs_no, :NEW.instrument_dt,
    :NEW.payment_mode, :NEW.payment_dt, :NEW.surchrg,
    :NEW.telephone_no, :NEW.cheque_number, :NEW.cheque_dt,
    :NEW.bank_code, :NEW.pay_amount, :NEW.receipt_no,
    :NEW.terminal_id, :NEW.crtn_by, :NEW.crtn_dt, :NEW.remarks,
    :NEW.status, :NEW.external_trans_id, :NEW.transfer_date,
    :NEW.gl_uploaded_ind_code, :NEW.task_queue_id,
    :NEW.user_name, :NEW.old_payment_id, :NEW.new_payment_id,
    :NEW.payment_type
    DELETE FROM z_errorpayment
    WHERE new_payment_id = :NEW.new_payment_id;
    END;
    so I thought of using a view inorder to get rid of the mutating error.
    But donno how to code it.
    could anyone please help me out.
    Regards,
    Rupa

    By using a view i wrote the below code:
    CREATE OR REPLACE TRIGGER row_trigger
    INSTEAD OF UPDATE
    ON Z_ErrorView
    FOR EACH ROW
    DECLARE
    X INTEGER;
    BEGIN
    SELECT STATUS into X FROM z_errorpayment WHERE new_payment_id = :NEW.new_payment_id;
    IF X=2 THEN
    INSERT INTO z_errorcorrected
    (mtnl_error_payment_id, file_name, entry_date,
    centre_code, service_code, instrument_flag,
    instrument_no, subs_no, instrument_dt,
    payment_mode, payment_dt, surchrg,
    telephone_no, cheque_number, cheque_dt,
    bank_code, pay_amount, receipt_no,
    terminal_id, crtn_by, crtn_dt, remarks,
    status, external_trans_id, transfer_date,
    gl_uploaded_ind_code, task_queue_id,
    user_name, old_payment_id, new_payment_id,
    payment_type
    VALUES (:NEW.mtnl_error_payment_id, :NEW.file_name, :NEW.entry_date,
    :NEW.centre_code, :NEW.service_code, :NEW.instrument_flag,
    :NEW.instrument_no, :NEW.subs_no, :NEW.instrument_dt,
    :NEW.payment_mode, :NEW.payment_dt, :NEW.surchrg,
    :NEW.telephone_no, :NEW.cheque_number, :NEW.cheque_dt,
    :NEW.bank_code, :NEW.pay_amount, :NEW.receipt_no,
    :NEW.terminal_id, :NEW.crtn_by, :NEW.crtn_dt, :NEW.remarks,
    :NEW.status, :NEW.external_trans_id, :NEW.transfer_date,
    :NEW.gl_uploaded_ind_code, :NEW.task_queue_id,
    :NEW.user_name, :NEW.old_payment_id, :NEW.new_payment_id,
    :NEW.payment_type
         END IF;
    DELETE FROM z_errorpayment
    WHERE new_payment_id = :NEW.new_payment_id;
    END;

  • Urgent:IMP-00017: following statement failed with ORACLE error 3113

    OS:HP_UX 11i
    Oracle 9.2.0.3.0
    when import tablespace metadata,
    comand is "imp \'sys/sysadmin AS sysdba\' TRANSPORT_TABLESPACE=y DATAFILES='/oradata/data2/
    B.dbf' TABLESPACES=A FILE=A.dmp IGNORE=Y LOG=./log/import.log"
    the error occurs as followed:
    Export file created by EXPORT:V09.02.00 via conventional path
    About to import transportable tablespace(s) metadata...
    import done in US7ASCII character set and AL16UTF16 NCHAR character set
    import server uses WE8ISO8859P1 character set (possible charset conversion)
    . importing SYS's objects into SYS
    IMP-00017: following statement failed with ORACLE error 3113:
    "BEGIN sys.dbms_plugts.beginImport ('9.2.0.3.0',31,'2000',NULL,'NULL',3626"
    "7,35051,1); END;"
    IMP-00003: ORACLE error 3113 encountered
    ORA-03113: end-of-file on communication channel
    IMP-00000: Import terminated unsuccessfully
    export is in same enviorment, the successful informantion below:
    exp \'sys/sysadmin AS sysdba\' TRANSPORT_TABLESPACE=y TABLESPACES=A FILE=A.dmp
    LOG=./log/export.log
    log file:
    Export done in US7ASCII character set and AL16UTF16 NCHAR character set
    server uses WE8ISO8859P1 character set (possible charset conversion)
    Note: table data (rows) will not be exported
    About to export transportable tablespace metadata...
    For tablespace A ...
    . exporting cluster definitions
    . exporting table definitions
    . . exporting table A
    . exporting referential integrity constraints
    . exporting triggers
    . end transportable tablespace metadata export
    Export terminated successfully without warnings.

    I do it,but the same error message.
    export message:
    Connected to: Oracle9i Enterprise Edition Release 9.2.0.3.0 - 64bit Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.3.0 - Production
    Export done in WE8ISO8859P1 character set and AL16UTF16 NCHAR character set
    Note: table data (rows) will not be exported
    About to export transportable tablespace metadata...
    For tablespace A ...
    . exporting cluster definitions
    . exporting table definitions
    . . exporting table A
    . exporting referential integrity constraints
    . exporting triggers
    . end transportable tablespace metadata export
    Export terminated successfully without warnings.
    Import Message:
    Export file created by EXPORT:V09.02.00 via conventional path
    About to import transportable tablespace(s) metadata...
    import done in WE8ISO8859P1 character set and AL16UTF16 NCHAR character set
    . importing SYS's objects into SYS
    IMP-00017: following statement failed with ORACLE error 3113:
    "BEGIN sys.dbms_plugts.beginImport ('9.2.0.3.0',31,'2000',NULL,'NULL',3627"
    "7,36451,1); END;"
    IMP-00003: ORACLE error 3113 encountered
    ORA-03113: end-of-file on communication channel
    IMP-00000: Import terminated unsuccessfully

  • How to avoid mutating error when insert or update record

    Hi ,
    I have one transaction table which is having some detail record under one transaction number, after the one transaction number is over by insert or update, i
    want to check the total amounts of one flag should be matched on same table if it is not then give error message. But i am getting mutating error on insert or update event trigger on statement level trigger on above table.
    Is there any other way to avoid mutating error to solve the above problem or some temp table concepts to be used. help me its urgent.
    Thanks in advance,
    Sachin Khaladkar
    Pune

    Sachin, here's as short of an example as I could come up with on the fly. The sample data is ficticious and for example only.
    Let's say I need to keep a table of items by category and my business rule states that the items in the table within each category must total to 100% at all times. So I want to insert rows and then make sure any category added sums to 100% or I will rollback the transation. I can't sum the rows in a row-level trigger because I'd have to query the table and it is mutating (in the middle of being changed by a transaction). Even if I could query it while it is mutating, there may be multiple rows in a category with not all yet inserted, so checking the sum after each row is not useful.
    So here I will create;
    1. the item table
    2. a package to hold my record collection (associative array) for the trigger code (the category is used as a key to the array; if I insert 3 rows for a given category, I only need to sum that category once, right?
    3. a before statement trigger to initialize the record collection (since package variables hang around for the entire database session, I need to clear the array before the start of every DML (INSERT in this case) statement against the item table)
    4. a before row trigger to collect categories being inserted
    5. an after statement trigger to validate my business rule
    I then insert some sample data so you can see how it works. Let me know if you have any questions about this.
    SQL> CREATE TABLE item_t
      2   (category  NUMBER(2)   NOT NULL
      3   ,item_code VARCHAR2(2) NOT NULL
      4   ,pct       NUMBER(3,2) NOT NULL);
    Table created.
    SQL>
    SQL> CREATE OR REPLACE PACKAGE trg_pkg IS
      2    TYPE t_item_typ IS TABLE OF item_t.category%TYPE
      3      INDEX BY PLS_INTEGER;
      4    t_item       t_item_typ;
      5    t_empty_item t_item_typ;
      6  END trg_pkg;
      7  /
    Package created.
    SQL> SHOW ERRORS;
    No errors.
    SQL>
    SQL> CREATE OR REPLACE TRIGGER item_bs_trg
      2    BEFORE INSERT
      3    ON item_t
      4  BEGIN
      5    DBMS_OUTPUT.put_line('Initializing...');
      6    trg_pkg.t_item := trg_pkg.t_empty_item;
      7  END item_bs_trg;
      8  /
    Trigger created.
    SQL> SHOW ERRORS;
    No errors.
    SQL>
    SQL> CREATE OR REPLACE TRIGGER item_br_trg
      2    BEFORE INSERT
      3    ON item_t
      4    FOR EACH ROW
      5  BEGIN
      6    trg_pkg.t_item(:NEW.category) := :NEW.category;
      7    DBMS_OUTPUT.put_line('Inserted Item for Category: '||:NEW.category);
      8  END item_br_trg;
      9  /
    Trigger created.
    SQL> SHOW ERRORS;
    No errors.
    SQL>
    SQL> CREATE OR REPLACE TRIGGER item_as_trg
      2    AFTER INSERT
      3    ON item_t
      4  DECLARE
      5    CURSOR c_item (cp_category item_t.category%TYPE) IS
      6      SELECT SUM(pct) pct
      7        FROM item_t
      8       WHERE category = cp_category;
      9  BEGIN
    10    DBMS_OUTPUT.put_line('Verifying...');
    11    FOR i IN trg_pkg.t_item.FIRST..trg_pkg.t_item.LAST LOOP
    12      DBMS_OUTPUT.put_line('Checking Category: '||trg_pkg.t_item(i));
    13      FOR rec IN c_item(trg_pkg.t_item(i)) LOOP
    14        IF rec.pct != 1 THEN
    15          RAISE_APPLICATION_ERROR(-20001,'Category '||trg_pkg.t_item(i)||' total = '||rec.pct);
    16        END IF;
    17      END LOOP;
    18    END LOOP;
    19  END item_as_trg;
    20  /
    Trigger created.
    SQL> SHOW ERRORS;
    No errors.
    SQL> INSERT INTO item_t
      2    SELECT 1, 'AA', .3 FROM DUAL
      3    UNION ALL
      4    SELECT 2, 'AB', .6 FROM DUAL
      5    UNION ALL
      6    SELECT 1, 'AC', .2 FROM DUAL
      7    UNION ALL
      8    SELECT 3, 'AA',  1 FROM DUAL
      9    UNION ALL
    10    SELECT 1, 'AA', .5 FROM DUAL
    11    UNION ALL
    12    SELECT 2, 'AB', .4 FROM DUAL;
    Initializing...
    Inserted Item for Category: 1
    Inserted Item for Category: 2
    Inserted Item for Category: 1
    Inserted Item for Category: 3
    Inserted Item for Category: 1
    Inserted Item for Category: 2
    Verifying...
    Checking Category: 1
    Checking Category: 2
    Checking Category: 3
    6 rows created.
    SQL>
    SQL> SELECT * FROM item_t ORDER BY category, item_code, pct;
      CATEGORY IT        PCT
             1 AA         .3
             1 AA         .5
             1 AC         .2
             2 AB         .4
             2 AB         .6
             3 AA          1
    6 rows selected.
    SQL>
    SQL> INSERT INTO item_t
      2    SELECT 4, 'AB', .5 FROM DUAL
      3    UNION ALL
      4    SELECT 5, 'AC', .2 FROM DUAL
      5    UNION ALL
      6    SELECT 5, 'AA', .5 FROM DUAL
      7    UNION ALL
      8    SELECT 4, 'AB', .5 FROM DUAL
      9    UNION ALL
    10    SELECT 4, 'AC', .4 FROM DUAL;
    Initializing...
    Inserted Item for Category: 4
    Inserted Item for Category: 5
    Inserted Item for Category: 5
    Inserted Item for Category: 4
    Inserted Item for Category: 4
    Verifying...
    Checking Category: 4
    INSERT INTO item_t
    ERROR at line 1:
    ORA-20001: Category 4 total = 1.4
    ORA-06512: at "PNOSKO.ITEM_AS_TRG", line 12
    ORA-04088: error during execution of trigger 'PNOSKO.ITEM_AS_TRG'
    SQL>
    SQL> SELECT * FROM item_t ORDER BY category, item_code, pct;
      CATEGORY IT        PCT
             1 AA         .3
             1 AA         .5
             1 AC         .2
             2 AB         .4
             2 AB         .6
             3 AA          1
    6 rows selected.
    SQL>

  • Trigger giving an error

    I have a trigger defined as follows:
    create or replace trigger TR_MY_TRIGGER after
    delete or
    update on member
    begin
    end;
    At the end of the trigger I have a SELECT on the member table, the table on which this trigger is based. I get a mutating error: ORA-04091: table member is mutating
    How can I get around this problem? I have tried to put the select in a procedure, but that does not work either. I have also tried to put pragma autonomous_transaction in the trigger, but to no avail.
    Thanks
    Edited by: user447219 on Nov 2, 2012 10:27 AM
    Edited by: user447219 on Nov 2, 2012 10:28 AM

    user447219 wrote:
    At the end of the trigger I have a SELECT on the member table, the table on which this trigger is based. So when you select from the table do you know if you are getting the new or old values that are both present in a row level trigger? And which values do you want?
    I get an error message: An error occured.ORA-20505| Error in DML| p_rowid=
    You actually get a different error
    http://docs.oracle.com/cd/E11882_01/server.112/e17766/e2100.htm#sthref1926
    >
    ORA-04091: table string.string is mutating, trigger/function may not see it
    You are just hiding it and replacing it with that useless message to make troubleshooting and debug more difficult.
    How can I get around this problem? I have tried to put the select in a procedure, but that does not work either. I have also tried to put pragma autonomous_transaction in the trigger, but to no avail.The mutating table error is like the safety catch on a gun that makes it go click when you aim it at your toes and pull the trigger. You should not work around it, it is trying to tell you what you are trying to do is not reliable. Autonomous transactions are not a fix for this.
    You should read this and then find a different way to do whatever it is you need to do.
    http://docs.oracle.com/cd/E11882_01/server.112/e25789/part_txn.htm#CHDJIGBH

  • Mutation error

    Hi,
    I have form in which we are creating parent child relation .The table structure is as follows
    problems(table name)(prom_number,prom_relation,prom_impact,prom_relation,...)(column name).
    I dont have the forms fmb file ,So whenwe create the relation 2 update statement gets executed first in problem table the prom_number which is parent in its problem_relation column its assigned as parent and the problem which is chilld in its column value assigne dare (prom_relation,prom_prom_number)(child,and the value or pro_number which is parent).
    Now our requirement is that the value of prom_impact of child should be assigned to problem which is parent,So i have written a trigger which update the prom_impact column whcih gives mutation error.SO how can we solve this issue.

    The trigger i have written is given below.
    The problem is that from form level the table is updated twice and in the trigger i try to update the row which is parent fault .howere its show mutation error.I even created trigger which shall commit the when from problem_rlation is cahnged to parent .so that in my trigger wheh i update the column prom_imapct field in trigger there should be no reeor.Still it given mutation error.
    CREATE OR REPLACE TRIGGER parent_child_impact_trg
    AFTER UPDATE /*OF prom_relation,prom_prom_number*/ ON PROBLEMS
    REFERENCING NEW AS NEW
    FOR EACH ROW
    Version History:9.2.8.1
    (format: version, date, developer, description)
    1.0, 19-Dec-2008, Tanmoy Kr Moulik The "Impact" of Paren fault ticket
    will be changed upon manual creation of Parent Child relation
    Rules:
    1.0     Upon manual creation of new Parent-Child fault relation, the 'Fault Impact' of
    Child fault will be auto updated in the parent fault, if the parent fault impact matches
    with the attached list(Non Serve Affeect or Threat) or the impact of Parent Fault is blank (null).
    2.0     In case, the parent fault have fault impact matches with the attached list
    (service affect), then its impact is not changed while making the relationship.
    DECLARE
    PRAGMA autonomous_transaction;
    ecode NUMBER;
    emesg VARCHAR2(200);
    --BEGIN
    -- NULL;
    CURSOR c1--(v_prom_num NUMBER)
    IS
    SELECT PROM_IMPACT,prom_number FROM PROBLEMS WHERE prom_number=:NEW.prom_prom_number;
    v_prom_imp VARCHAR2(30) DEFAULT NULL;
    v_prom_imp_p1 NUMBER DEFAULT 0;
    v_prom_imp_p2 NUMBER DEFAULT 0;
    v_prom_num NUMBER;
    BEGIN
    IF :NEW.PROM_RELATION='CHILD' AND :NEW.PROM_PROM_NUMBER IS NOT NULL THEN
    --dbms_output.put_line(1);
    --INSERT INTO TEMP_PROM VALUES(:NEW.prom_number,:NEW.prom_prom_number,:NEW.prom_impact,:NEW.prom_relation);
    --COMMIT;
    OPEN c1;--(:NEW.prom_prom_number);
    FETCH c1 INTO v_prom_imp,v_prom_num;
    --INSERT INTO TEMP_PROM(PROM_NUM,PROM_IMPACT) VALUES(v_prom_num,v_prom_imp);
    --COMMIT;
    IF c1%NOTFOUND THEN
    v_prom_imp:=NULL;
    v_prom_num:=NULL;
    END IF;
    CLOSE c1;
    v_prom_imp:=UPPER(v_prom_imp);
    v_prom_imp_p1:=INSTR(v_prom_imp,'NON');
    v_prom_imp_p2:=INSTR(v_prom_imp,'THREAT');
    --INSERT INTO TEMP_PROM(PROM_NUM) VALUES(v_prom_imp_p1);
    --INSERT INTO TEMP_PROM(PROM_NUM) VALUES(v_prom_imp_p2);
    --COMMIT;
    IF v_prom_imp_p1>0 /*OR v_prom_imp_p2>0*/ THEN
    IF :NEW.prom_impact IS NOT NULL THEN
    BEGIN
    INSERT INTO TEMP_PROM(PROM_NUM,PROM_PROM_NUMBER,prom_impact,PROM_RELATION) VALUES(:NEW.prom_number,:NEW.prom_prom_number,:NEW.prom_impact,:NEW.prom_relation);
    COMMIT;
    EXCEPTION WHEN OTHERS THEN
    INSERT INTO TEMP_PROM(prom_impact,PROM_RELATION) VALUES('failed1'||ecode,emesg);
    END;
    BEGIN
    COMMIT;
    UPDATE PROBLEMS SET PROM_IMPACT=:NEW.PROM_IMPACT WHERE prom_number=:NEW.prom_prom_number;
    COMMIT;
    EXCEPTION WHEN OTHERS THEN
         ecode := SQLCODE;
    emesg := SQLERRM;
    -- BEGIN
    INSERT INTO TEMP_PROM(prom_impact,PROM_RELATION) VALUES('failed'||ecode,emesg);
    COMMIT;
    -- EXCEPTION WHEN OTHERS THEN*/
         NULL;
         --END;
    END;     
    END IF;     
         /*BEGIN
         INSERT INTO TEMP_PROM(PROM_NUM,PROM_IMPACT) VALUES(:NEW.prom_prom_number,:NEW.prom_impact);
         COMMIT;
    EXCEPTION WHEN OTHERS THEN
         INSERT INTO TEMP_PROM(prom_impact) VALUES('failed1');
         NULL;
         END;
    --NULL;
    -- END;
    --COMMIT;
    --END;
    /* BEGIN
    INSERT INTO TEMP_PROM(PROM_NUM,PROM_IMPACT) VALUES(:NEW.prom_prom_number,:NEW.prom_impact);
    EXCEPTION WHEN OTHERS THEN
    --INSERT INTO TEMP_PROM(prom_impact) VALUES('failed');
    NULL;
    END;
    COMMIT;
    --COMMIT;
    /* ELSIF v_prom_imp_p2>0 THEN
    -- v_prom_imp_p2
    IF :NEW.prom_impact IS NOT NULL THEN
    BEGIN
    UPDATE PROBLEMS SET PROM_IMPACT=:NEW.PROM_IMPACT WHERE prom_number=:NEW.prom_prom_number;
    EXCEPTION WHEN OTHERS THEN
    BEGIN
         ecode := SQLCODE;
    emesg := SQLERRM;
    --BEGIN
    INSERT INTO TEMP_PROM(prom_impact,PROM_RELATION) VALUES('failed'||ecode,emesg);
    COMMIT;
    --EXCEPTION WHEN OTHERS THEN
         NULL;
         END;
    NULL;
    END;
    COMMIT;
    BEGIN
    INSERT INTO TEMP_PROM(PROM_NUM,PROM_IMPACT) VALUES(:NEW.prom_prom_number,:NEW.prom_impact);
    EXCEPTION WHEN OTHERS THEN
    NULL;
    END;
    COMMIT;*/
    --UPDATE PROBLEMS SET PROM_IMPACT=:NEW.PROM_IMPACT WHERE prom_number=:NEW.prom_prom_number;
    -- COMMIT;
    -- END IF;
    END IF;
    END IF;
    EXCEPTION WHEN OTHERS THEN
    INSERT INTO TEMP_PROM(prom_impact,PROM_RELATION) VALUES('failed2'||ecode,emesg);
    COMMIT;
    NULL;
    END;

  • How to handle the mutating error

    create or replace trigger trg_t1
    after insert on t1
    begin
    insert into t1 values(1);
    end;
    i got some error..

    1011927 wrote:
    same table with the same trigger
    Within  trigger code do not issue SQL against same table upon which trigger is based; then no mutating error is thrown

  • URGENT : Trigger

    Hi,
    I'm trying to write a trigger on a Table ROOM_BLOCK to update a value in table ROOM_OOI_OOS.
    As given below, which works perfectly.
    BEGIN
    IF INSERTING THEN
    IF NVL(:NEW.ROOM_OOI_OOS_ID,0) <> 0 THEN
    UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)+1
    WHERE ROOM_OOI_OOS_ID = :NEW.ROOM_OOI_OOS_ID;
    END IF;
    ELSIF UPDATING THEN
    IF NVL(:OLD.ROOM_OOI_OOS_ID,0) <> 0 THEN
    UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)-1
    WHERE ROOM_OOI_OOS_ID = :OLD.ROOM_OOI_OOS_ID;
    END IF;
    IF NVL(:NEW.ROOM_OOI_OOS_ID,0) <> 0 THEN
    UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)+1
    WHERE ROOM_OOI_OOS_ID = :NEW.ROOM_OOI_OOS_ID;
    END IF;
    ELSE
    IF NVL(:OLD.ROOM_OOI_OOS_ID,0) <> 0 THEN
    UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)-1
    WHERE ROOM_OOI_OOS_ID = :OLD.ROOM_OOI_OOS_ID;
    END IF;
    END IF;
    END;
    But when I add a select statement. the trigger seems to fail with a mutating error ORA-04091
    and Error at Line which executes the statement immidiate ORA-04088.
    DECLARE
    stmt VARCHAR2(500);
    vcount INTEGER;
    BEGIN
    IF INSERTING THEN
    --INSERT INTO SHRUTI_TEST (DESCR) VALUES ('Inserting');
    IF NVL(:NEW.ROOM_OOI_OOS_ID,0) <> 0 THEN
    stmt := 'Select count(*) from ROOM_BLOCK ' ||
    ' WHERE ROOM_OOI_OOS_ID = ' || :NEW.ROOM_OOI_OOS_ID ||
    ' AND ROOM_NO = ''' || :NEW.ROOM_NO || ''' ';
    EXECUTE IMMEDIATE stmt INTO vcount;
    IF vcount = 1 THEN
    UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)+1
    WHERE ROOM_OOI_OOS_ID = :NEW.ROOM_OOI_OOS_ID;
    END IF;
    END IF;
    ELSIF UPDATING THEN
    IF NVL(:OLD.ROOM_OOI_OOS_ID,0) <> 0 THEN
    UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)-1
    WHERE ROOM_OOI_OOS_ID = :OLD.ROOM_OOI_OOS_ID;
    END IF;
    IF NVL(:NEW.ROOM_OOI_OOS_ID,0) <> 0 THEN
    UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)+1
    WHERE ROOM_OOI_OOS_ID = :NEW.ROOM_OOI_OOS_ID;
    END IF;
    ELSE
    IF NVL(:OLD.ROOM_OOI_OOS_ID,0) <> 0 THEN
    UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)-1
    WHERE ROOM_OOI_OOS_ID = :OLD.ROOM_OOI_OOS_ID;
    END IF;
    END IF;
    END;
    Please tell me how to solve this problem...
    Regards
    Mike.

    Read the following link.
    http://asktom.oracle.com/~tkyte/Mutate/index.html

Maybe you are looking for