I have had a problem with foreign keys. I have created a set of triggers that should cascade deletes through database if a row in table is deleted so that all its children (and children of those children) would be deleted. Here is an example of such trigger.
create or replace trigger trigg_delet_child before delete on PARENT for
each row
begin
delete from CHILD where foreign_key_parent_id = :old.id_parent;
end;
I have a set of such triggers on each table. I have assumed that since the trigger should fire before the delete statement is executed, and therefore passes the torch to lower and lower tables until we finally hit item without children and begin delete from there and work our way up.
This does not appear to be the case, as a foreign_key constraint is rather understandably violated, because apparently i misunderstood how BEFORE works. Is there a way to sidestep this issue without specifying that the foreign_key constraint should cascade on delete?
on delete cascade? - a_horse_with_no_nameafter delete? - kfinity