Q

Mutating table error with on delete cascade trigger

I have a grandparent table, a parent table and three child tables. Those tables have a delete cascade constraint defined on each level. I need to copy the parent and three child tables' data for that particular parent to another staging table (one for each table) if there is a delete on the parent table. No action is needed if the delete occurs in the grandparent table. How could I implement this through a trigger? I get a table mutating...

error.

First, see this site for several different mutating table error solutions.

Second, remember that in a trigger you cannot try to manipulate the table that "triggered the trigger". But, you have all the :old.column values available to you which contain the values prior to the delete action occurring. Your trigger should be using these values to populate your staging tables and NOT be trying to re-read the parent table to get any data.

For More Information


This was first published in January 2003
This Content Component encountered an error

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide

SearchDataCenter

SearchContentManagement

SearchFinancialApplications

Close