--将所有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%‘;
时间: 2024-10-05 04:41:22