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...
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
- Dozens more answers to tough Oracle questions from Karen Morton are available.
- The Best Oracle Web Links: tips, tutorials, scripts, and more.
- Have an Oracle or SQL tip to offer your fellow DBAs and developers? The best tips submitted will receive a cool prize. Submit your tip today!
- Ask your technical Oracle and SQL questions -- or help out your peers by answering them -- in our live discussion forums.
- Ask the Experts yourself: Our SQL, database design, Oracle, SQL Server, DB2, metadata, object-oriented and data warehousing gurus are waiting to answer your toughest questions.
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.