If it only has to happen for that specific action, then you need to add
that delete code to the specific procedure that executes that action, of
course instead of :old.parent_id, you need to use an appropriate local
variable. For example:
CREATE PROCEDURE delete_child (child_id integer)
AS
DECLARE parent_id INTEGER;
BEGIN
DELETE FROM child
WHERE id = :child_id
RETURNING parent_id INTO parent_id;
BEGIN
DELETE FROM parent
WHERE id = :parent_id;
WHEN GDSCODE foreign_key DO
BEGIN
-- ignore
END
END
END
NOTE: The nested BEGIN .. END block is necessary to prevent a foreign
key violation when deleting from child to be ignored as well.
Or use RDB$SET_CONTEXT / RDB$GET_CONTEXT to signal to the trigger if it
is appropriate to run or not.
Mark
--
Mark Rotteveel