0

I have this task to emulate a referential action with a trigger. The task itself is: Give an example of how to use a trigger to emulate a referential action.

I know hot to use triggers and referential actions but combined I just don't really get it, and the question itself.

Milkncookiez
  • 6,817
  • 10
  • 57
  • 96

1 Answers1

1

Given that the least objectionable of the options you listed is to do a cascading delete when a parent row is removed

CREATE OR REPLACE TRIGGER trigger_name
  AFTER DELETE ON parent_table
  FOR EACH ROW
BEGIN
  DELETE FROM child_table
   WHERE parent_id = :old.parent_id;

  <<repeat for each child table>>
END;
Justin Cave
  • 227,342
  • 24
  • 367
  • 384
  • 1
    So I basically had to simulate the referential action through basic logical statements. That is what I needed to understand. Thank you! – Milkncookiez Jun 14 '13 at 13:41