-- cascade.sql

CREATE OR REPLACE TRIGGER person_id_trig
 AFTER UPDATE OF id ON person
   FOR EACH ROW
DECLARE
BEGIN
   UPDATE employee
      SET id = :new.id
    WHERE id = :old.id;
   UPDATE account
      SET customer_id = :new.id
    WHERE customer_id = :old.id;
   UPDATE order_header 
      SET customer_id = :new.id
    WHERE customer_id = :old.id;
   UPDATE vendor
      SET vendor_rep_id = :new.id
    WHERE vendor_rep_id = :old.id;
END;
/
CREATE OR REPLACE TRIGGER employee_id_trig
 AFTER UPDATE OF id ON employee
   FOR EACH ROW
DECLARE
BEGIN
   UPDATE store
      SET manager_id = :new.id
    WHERE manager_id = :old.id;
/*
The following update won't work, because
we are trying to update a mutating table!
   UPDATE employee
      SET supervisor_id = :new.id
    WHERE supervisor_id = :old.id;
*/
END;
/
