Cascading Triggers:
Triggers are said to be cascading when the body of the trigger causes another trigger to be fired. Let consider an example like that whenever a product is deleted in the product table the corresponding record in the ordprd table must be deleted. The subsequent trigger is created for the ordprd table:
CREATE OR REPLACE TRIGGER ORDPRDDEL AFTER DELETE ON ORDPRD
DECLARE
X NUMBER:=0;
BEGIN
SELECT COUNT(*) INTO X FROM ORDPRD; DBMS_OUTPUT.PUT_LINE('RECORD DELETED');
DBMS_OUTPUT.PUT_LINE('RECORDS AVAILABLE ARE '||X);
END;
/ CREATE OR REPLACE TRIGGER PRODDEL AFTER DELETE ON PRODUCT FOR EACH ROW
BEGIN
DELETE FROM ORDPRD WHERE PCODE=:OLD.PCODE;
END;
When a record is deleted,
DELETE FROM product WHERE pcode=102;
record deleted
records available are 18