CREATE TABLE depart
(zf CHAR(3),
dw CHAR(20))
/
CREATE TABLE employee
(xm CHAR(20),
dw CHAR(20))
/
CREATE OR REPLACE TRIGGER tridepart
BEFORE DELETE
ON depart
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
BEGIN
delete employee where dw =
ld.dw;
commit;
END;
/
insert into depart values('111','123');
insert into depart values('111','234');
insert into depart values('111','345');
insert into depart values('222','456');
insert into depart values('222','567');
insert into employee values('aaa','123');
insert into employee values('bbb','234');
insert into employee values('ccc','345');
insert into employee values('ddd','456');
insert into employee values('eee','567');
SELECT zf, dw FROM depart;
ZF DW
----------------
111 123
111 234
111 345
222 456
222 567
SELECT xm, dw FROM employee;
XM DW
-------------------------
aaa 123
bbb 234
ccc 345
ddd 456
eee 567
delete depart where zf='222';
SELECT zf, dw FROM depart;
ZF DW
----------------
111 123
111 234
111 345
SELECT xm, dw FROM employee;
XM DW
-------------------------
aaa 123
bbb 234
ccc 345