Ralf Junker <[EMAIL PROTECTED]> wrote:
I was looking for recursive delete triggers because the information I
need to store in a single table is hierarchical in a sense that a
record can refer to another record in the same table (like when
storing a tree structure). With recursive delete triggers, a single
delete would automatically delete all children AND GRANDCHILDREN of
that tree's node. Deleting children with triggers is possible without
recursion, but you need recursive delete triggers to delete the
grandchildren also.
Well, you don't strictly _need_ recursive triggers (as in, can't
implement the same functionality without them), they are just more
convenient. You can always write
create trigger del_parents delete on parents
begin
delete from grandchildren
where parentId in
(select id from children where parentId = old.id);
delete from children where parentId = old.id;
end;
create trigger del_children delete on children
begin
delete from grandchildren where parentId = old.id;
end;
Igor Tandetnik