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

Thread: mutating table problem

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Posts
    37

    Unhappy mutating table problem

    Suppose I have table with following fields

    Id
    Name
    Salary
    Bonus

    I want to create a trigger to populate bonus field as 10% of salary during insert/update.

    However, when I tried to write a trigger I got mutating table error. After consulting a PL/SQL book, I ultimately made a way by using package and a PL/SQL table to track which Ids were inserted/updated and then call another trigger statement to update the Bonus.

    Now my question is, why Oracle does the things in this way? SQL Server implements it in much more easy & straigh forward manner.

    Thanx

  2. #2
    Join Date
    Jun 2000
    Location
    Madrid, Spain
    Posts
    7,447

  3. #3
    Join Date
    Dec 2003
    Location
    pune,india
    Posts
    7

    Lightbulb

    dear member
    this problem is called mutating triggers.this happens with row triggers.the only solution to this is to use statement triggers or go for normalization.u can not rectify the problem wit h row trigger
    n santoh

  4. #4
    Join Date
    Nov 2002
    Location
    Geneva Switzerland
    Posts
    3,142
    ! ! ! ! ! !

    What's wrong with
    :new.bonus := 0.1 * :new.salary;
    in a before trigger?

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