如何使用oracle触发列更改触发器 [英] how to fire trigger on column change using oracle

查看:71
本文介绍了如何使用oracle触发列更改触发器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在m_service上更新后创建或替换触发器trg_m_service


每行


声明

create or replace trigger trg_m_service
after update on m_service
for each row
declare

begin
 if updating(SRM_THEFT_CASE_STATUS)then
  update m_servicemaster@collection
  set srm_theft_tag@collection =:new.SRM_THEFT_CASE_STATUS,
  srm_theft_amt@collection =:new.srm_theft_amt,srm_modify_date=sysdate
  where :new.srm_service_no=srm_service_no@collection;
 end if;
end;

推荐答案

您可以使用前缀:旧和:新测试列值是否更改



创建或替换触发器trg_m_service

更新后的m_service

每行b

开始

如果:Old.SRM_THEFT_CASE_STATUS!=:New.SRM_THEFT_CASE_STATUS那么



- - 你的更新



结束如果;



结束;
You can use prefix :Old and :New to test if column value as changed

create or replace trigger trg_m_service
after update on m_service
for each row
Begin
If :Old.SRM_THEFT_CASE_STATUS != :New.SRM_THEFT_CASE_STATUS Then

-- your update

End If;

End;


begin
 if updating(SRM_THEFT_CASE_STATUS)then
  update m_servicemaster@collection
  set srm_theft_tag@collection =:new.SRM_THEFT_CASE_STATUS,
  srm_theft_amt@collection =:new.srm_theft_amt,srm_modify_date=sysdate
  where :new.srm_service_no=srm_service_no@collection;
 end if;
end;


这篇关于如何使用oracle触发列更改触发器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆