Is an after delete trigger allowed on a table that has a foreign key constraint with a cascade delete action?
To test, I've defined an Order and OrderDetail table, and I'm trying to add an after delete trigger on the OrderDetail table, but i'm getting the error:
... "Constraint rule DELETE CASCADE is not allowed with a delete trigger."...
However, I read the following from an IBM redbook:
Delete
A delete trigger is activated if a database row is deleted by using the SQL statement
DELETE or a delete in native I/O, etc. A delete trigger can also be fired as result of a
referential constraint clause ON DELETE CASCADE.
For example, you defined in your constraint that all Order Detail rows must be deleted if
the associated header is deleted. Additionally, you put an AFTER DELETE trigger on the
Order Detail table. When deleting the Order Header, this trigger will be fired.
I don't see why you can't have a delete trigger on a table that has a cascade delete action.