goldengate OCI Error ORA-01400: cannot insert NULL

     goldengate目标端出现 OCI Error ORA-01400: cannot insert NULL

     我分析可能遇到的一种情况是,目标端开启了HANDLECOLLISIONS ,当源端update一条记录时,目标端没有这条记录,如果更新的是主键,就会转换为insert语句,但是默认只是插入主键,如果更新的非主键列会被抛弃并且不会记录错误到discard

 

   如果更新的是主键列,但是这个表的其他的列要是有非空的限制,就会报错

 

 

源端:

        

SQL>  create table t1 (id int primary key,name varchar2(20) not null);

Table created.
SQL> insert into t1 values(1,'nag');

1 row created.

SQL> commit;

Commit complete.

SQL> select * from t1;

        ID NAME
---------- --------------------
         1 nag

 

目标端:

SQL> select * from t1;

        ID NAME
---------- --------------------
         1 nag

SQL> delete from t1;

1 row deleted.

SQL> commit;

Commit complete.

SQL> select * from t1;

no rows selected

 

源端:

update t1 set name='namu' where id=1;


SQL> update t1 set name='namu' where id=1;

1 row updated.

SQL> commit;

Commit complete.

SQL> select * from t1;

        ID NAME
---------- --------------------
         1 namu

 

目标端:

stats replt1 发现有一个update被记录,但是目标端没有执行,日志也没有报错


SQL> select * from t1;

no rows selected

 

源端:

update t1 set id=3 where id=1;

 

目标端:

2013-03-20 15:00:43  INFO    OGG-00996  Oracle GoldenGate Delivery for Oracle, replt1.prm:  REPLICAT REPLT1 started.
2013-03-20 15:00:43  WARNING OGG-01396  Oracle GoldenGate Delivery for Oracle, replt1.prm:  A complete after image is not available in SCOTT.T1 at rba 3335 in file /u01/app/goldengate/dirdat/tt000004, while inserting a row into TEST.T1 due to missing target row for a key update operation. NOCOMPRESSUPDATES or FETCHOPTIONS FETCHPKUPDATECOLS may be specified in the EXTRACT parameter file to include a complete image for key update operations.
2013-03-20 15:00:43  WARNING OGG-00869  Oracle GoldenGate Delivery for Oracle, replt1.prm:  OCI Error ORA-01400: cannot insert NULL into ("TEST"."T1"."NAME") (status = 1400). INSERT /*+ RESTRICT_ALL_REF_CONS */ INTO "TEST"."T1" ("ID") VALUES (:a0).
2013-03-20 15:00:43  WARNING OGG-01004  Oracle GoldenGate Delivery for Oracle, replt1.prm:  Aborted grouped transaction on 'TEST.T1', Database error 1400 (OCIError ORA-01400: cannot insert NULL into ("TEST"."T1"."NAME") (status = 1400). INSERT /*+RESTRICT_ALL_REF_CONS */ INTO "TEST"."T1" ("ID") VALUES (:a0)).
2013-03-20 15:00:43  WARNING OGG-01003  Oracle GoldenGate Delivery for Oracle, replt1.prm:  Repositioning to rba 3335 in seqno 4.
2013-03-20 15:00:43  WARNING OGG-01154  Oracle GoldenGate Delivery for Oracle, replt1.prm:  SQL error 1400 mapping SCOTT.T1 to TEST.T1 OCI Error ORA-01400: cannot insert NULL into ("TEST"."T1"."NAME") (status = 1400). INSERT /*+ RESTRICT_ALL_REF_CONS */ INTO "TEST"."T1" ("ID") VALUES (:a0).
2013-03-20 15:00:43  WARNING OGG-01003  Oracle GoldenGate Delivery for Oracle, replt1.prm:  Repositioning to rba 3335 in seqno 4.
2013-03-20 15:00:43  ERROR   OGG-01296  Oracle GoldenGate Delivery for Oracle, replt1.prm:  Error mapping from SCOTT.T1 to TEST.T1.
2013-03-20 15:00:43  ERROR   OGG-01668  Oracle GoldenGate Delivery for Oracle, replt1.prm:  PROCESS ABENDING.

 

 

  

     可以在源端开启FETCHOPTIONS FETCHPKUPDATECOLS将捕获完整的redo image镜像到trail中 这样保证插入完整的记录

   但是建议关闭目标端的HANDLECOLLISIONS,因为update非主键列会有数据丢失

  源端:

SQL> insert into t1 values(1,'nag');

1 row created.

SQL> commit;

 

目标:

SQL> select * from t1;

        ID NAME
---------- --------------------
         1 nag

 

SQL> delete from t1;

1 row deleted.

SQL> commit;

Commit complete.

 

 

源端:

 


SQL> update t1 set id=2 where id=1;

1 row updated.

SQL> commit;

 

 

目标:

SQL> select * from t1;

        ID NAME
---------- --------------------
        2     nag

 

 

 

参考文档:

http://www.askmaclean.com/archives/%e4%ba%86%e8%a7%a3goldengate-replicat%e7%9a%84handlecollisions%e5%8f%82%e6%95%b0.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值