--将所有HY开头的表都生成一个更新触发器的脚本(\'/\'是为了连续创建多个触发器而不报错)
select
\'CREATE OR REPLACE TRIGGER \'||table_name||\' BEFORE UPDATE on \'||table_name||\' REFERENCING NEW AS NEW OLD AS OLD FOR EACH ROW DECLARE BEGIN IF updating THEN :NEW.C_UPDATE_TIME:= SYSDATE; IF :NEW.C_DATA_STATUS=\'\'4\'\' THEN :NEW.C_DATA_STATUS:=\'\'4\'\'; ELSE :NEW.C_DATA_STATUS:=\'\'2\'\'; END IF; END IF; END; / alter trigger \'||table_name||\' enable;\' as triggerSql from tabs where table_name like \'HY%\' order by table_name;
--:NEW.C_DATA_STATUS:=\'\'4\'\'中的:=是赋值,\'\'是转义单引号 --查询触发器
select trigger_name from all_triggers where trigger_name like \'HY%\';
--查询用户触发器
select trigger_name from user_triggers;

 

版权声明:本文为xmqa原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/xmqa/p/7083244.html