Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

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

user8267059Sep 10 2008 — edited Sep 11 2008
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!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 9 2008
Added on Sep 10 2008
8 comments
576 views