simple trigger
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: simple trigger

  1. #1
    Join Date
    Jan 2001
    Posts
    642
    Hi,

    I want to update one of the columns with the sum of 2 other columns on the same table.

    I have written a trigger, which works fine with insert statements but on update, it's mutating. Whats the round about way of doing it.
    Egs:
    /******works fine************/
    create or replace trigger t_nbn1
    after insert on nbn1
    begin
    update nbn1
    set c3 = c1 + c2;
    end;
    /*********************MUTATING PROBLEM****/
    create or replace trigger tu_nbn1
    after update on nbn1
    for each row
    begin
    update nbn1
    set c3 = c1 + c2;
    end;
    *************************************************
    Badrinath


  2. #2
    Join Date
    Oct 2000
    Location
    Saskatoon, SK, Canada
    Posts
    3,925
    Refer:
    Note: 74859.1
    Note: 37906.1
    Note: 135051.1

    From the metalink...

    Sam
    Thanx
    Sam



    Life is a journey, not a destination!


  3. #3
    Join Date
    Mar 2001
    Posts
    314
    Will the following do?

    create or replace trigger trig_t1
    before insert or update on t1
    for each row
    begin
    :new.c3 := :new.c1 + :new.c2;
    end trig_t1;

    -amar

  4. #4
    Join Date
    Feb 2001
    Posts
    20

    Arrow use this one

    create or replace trigger xy
    before insert or update on ccc
    for each row
    begin
    If inserting then
    :new.x := :new.y+:new.z;
    end if;
    If updating then

    :new.x := ld.y+ld.z;
    end if;
    end;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width