We are trying to implement cascade delete trigger on parent table and
we are expecting the following actions:
1) All records in the child tables should be deleted
2) The record in the parent table should be deleted
For example,
Parent Table= Customer
Customer_id (PK), Customer_name
1 Smith, John
2 Murphy, Jack
3 Skokan, Anne
Child Table= Orders
Customer_id(FK), Order_id
1 100
1 101
1 102
...
Primary key for order table is(Customer_id, Order_id)
While deleting a record where Customer= 1 from Customer, we are
expecting the following actions:
1) (1,100 1,101 1,102) in the Order table should be deleted
2) The record 1 from Customer table should be deleted
we implemented the following trigger:
CREATE Trigger tD_Customer DELETE on CustomerReferencing OLD as DELETED
for each row (DELETE FROM ORDERS WHERE Orders.Customer_id=
Deleted.Customer_id);
When we tried to delete Customer record, we got error no -692 , which
is referential integrity constraint. Please help!
P.S. We tried "Before action" clause also.