ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 触发器实时实现同步-问题

触发器实时实现同步-问题

原创 Linux操作系统 作者:chwang1984 时间:2011-11-09 17:29:42 0 删除 编辑

采用事务独立性,以及单个sql语句捕获异常的方式,实现跨网段建触发器同步数据,造成源数据库插入不成功的现场。       例如:

CREATE OR REPLACE TRIGGER cltx_tri_i
 AFTER INSERT ON cltx
REFERENCING NEW AS NEW OLD AS OLD
 FOR EACH ROW
DECLARE
    PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
    BEGIN
        INSERT INTO cltx@mzz_lnk (road,
                                  fxbh,
                                  cdh,
                                  hphm,
                                  jgsj,
                                  cllx,
                                  clsd,
                                  bj,
                                  wf,
                                  qmtp,
                                  xs,
                                  csbfb)
          VALUES   (:new.road,
                    :new.fxbh,
                    :new.cdh,
                    :new.hphm,
                    :new.jgsj,
                    :new.cllx,
                    :new.clsd,
                    :new.bj,
                    :new.wf,
                    :new.qmtp,
                    :new.xs,
                    :new.csbfb);

        COMMIT;
    EXCEPTION
        WHEN OTHERS
        THEN
            ROLLBACK;
    END;
EXCEPTION
    WHEN OTHERS
    THEN
        DBMS_OUTPUT.put_line (
            LOCALTIMESTAMP || ', ' || SQLCODE || ': ' || SQLERRM);
        --COMMIT;
END;
/

 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/17179887/viewspace-710511/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2009-03-27

  • 博文量
    96
  • 访问量
    169742