Results 1 to 2 of 2

Thread: mutating trigger

  1. #1
    Junior Member
    Join Date
    Feb 2007
    Answers
    3

    mutating trigger

    hi everybody
    can anyone explain me what is mutating trigger.


  2. #2
    Contributing Member
    Join Date
    Jan 2007
    Answers
    31

    Re: mutating trigger

    Hi, a mutating trigger occurs in oracle when the table that originally fired the triggering event is being accessed in the body of the trigger code, directly or implicitly in a procedure, or in a nested trigger called from the trigger body.

    This action is forbidden because the table is in middle of a transaction, and referencing the same table again in the middle of the updating action causes the trigger to mutate. For example:

    sql>create table t1 (x int);

    sql>create table t2 (x int);

    sql>insert into t1 values (1);

    sql>select * from t1;

    sql>select * from t2;

    sql>create or replace trigger t_trigger

    after insert on t1

    for each row

    declare

    i pls_integer;

    begin

    select count(*) into i from t1;

    insert into t2 values (i);

    end; /

    sql>insert into t1 values (1);

    sql>select count(*) from t1;

    sql>select count(*) from t2;

    if u run this one u will get the mutating error, ora-04091.

    Cheers, regards

    rsy

    Last edited by raghav_sy; 02-08-2007 at 02:57 AM. Reason: code formatting was lost..........

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact