论坛首页 Java企业应用论坛

Oracle数据库用触发器实现两张表数据同步

浏览 5806 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2008-11-13  
编写触发器实现两张表数据同步,sql代码如下:
create or replace trigger buid_mend_manager
    after insert or update or delete 
    on TMP_EIC_MEND
    referencing old as old_value
                new as new_value
    for each row
begin
    if inserting then
      insert into Eic_mend(mendid, mendname) 
      values(:new_value.mendid, :new_value.mendname);
    elsif updating then
      update Eic_mend set mendname = :new_value.mendname 
      where mendid = :new_value.mendid;
    elsif deleting then
      delete from Eic_mend where mendid = :old_value.mendid;
    end if;
end;
论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics