--创建触发器 --FOR EACH ROW 代表行级触发器 --:NEW 代表操作完成后列的值 --:OLD 代表操作前列的值 --INTO 用于赋值给变量 --BEFORE|AFTER 触发器的触发时间是前触发还是后触发 CREATE OR REPLACE TRIGGER tr_del_check BEFORE DELETE ON T_AAA_TABLE FOR EACH ROW DECLARE fid varchar2 (128); detail_count NUMBER; BEGIN CASE WHEN DELETING THEN fid:=:OLD.FID; SELECT COUNT(1) INTO detail_count FROM T_BBB_TABLE where FBILLID = FID; IF detail_count > 1 THEN RAISE_APPLICATION_ERROR(-20600,'BBB表数据未删除,不能删除调动单!'); END IF; END CASE; END; --删除触发器 drop trigger tr_del_check --查询数据表上的触发器,表明要全大写 select * from all_triggers WHERE table_name='T_AAA_TABLE'
标签:count,触发器,END,--,detail,Oracle,TABLE From: https://www.cnblogs.com/oioele/p/16927741.html