Re: Delete Cascade & Delete Triggers
Posted in 1997
Chad Chervitz wrote: > > I have 2 tables, parent and child (P & C). C has an on delete cascade > reference constraint, referencing P. This is so that if P row is > deleted, C rows are also. > > But I also need something to happen when C rows are deleted (which can > happen independantly of P row being deleted), so I tried to create a > DELETE trigger on C. > > But Informix tells me I can't create a DELETE trigger on a table > participating in an ON DELETE CASCADE. Is this true? How do I go > about trapping deletes on C? BTW, one restriction -- I can't modify > the client side of the application (i.e., so I can't just follow the > C delete statement with another step inside the client app). HMmm... That's a strange restriction! As annoying as some other silly restrictions on an update trigger and the columns it may reference. However, you might drop the cascaded delete and instead, use a delete trigger on the parent table: If I delete a row from the parent table, the delete trigger on the parent table will delete the appropriate rows in the child table. Then the delete trigger on the child table can proceed... I think. (Famous last words..) Let us know (on this thread) how that works. -- -- Jake (Never yelled "CROWDED THEATER!" during a fire) +------------------------------------------------------------+ | The expedient performance of a task with excessive concern | | regarding its duration-to-completion engenders a virtual | | certainty of diminished benefit therefrom. | | -- Benjamin Franklin (but he said it in 3 words) | +------------------------------------------------------------+