你好,触发器如下,经过测试哦!、
创建触发器:
CREATE OR REPLACE TRIGGER TR_UPDATE
AFTER UPDATE ON TABLE2---当修改了TABLE2时触发
FOR EACH ROW
when (OLD.FENLEI='0000')--当tabel2的fenlei值为0000时触发操作
BEGIN
CASE
WHEN UPDATING('ZHI') THEN
UPDATE TABLE1 SET nianxian=:NEW.ZHI WHERE dangan=:OLD.dangan AND bingan=:OLD.bingan;
END CASE;
END;
修改tabel2的数据,即可在table1中看到结果,希望能采取我的答案哦~
参考一下:
CREATE OR REPLACE TRIGGER "TRI_TABLE2"
AFTER INSERT OR UPDATE OR DELETE ON TABLE2
FOR EACH ROW
BEGIN
IF UPDATING THEN
update table1 t1 set t1.nianxian = (select t2.zhi from table t2
where 1=1
and t1.dangan = t2.dangan
and t1.bingan = t2.bingan
and t2.fenlei = '0000'
)
where 1=1
and exists (select 1 from table t2
where t1.dangan = t2.dangan
and t1.bingan = t2.bingan
and t2.fenlei = '0000')
;
END IF;
END TRI_TABLE1;
/