首页 > 其他 > 详细

OGG-字段符合特定条件,转换为某些特定字符,测试

时间:2021-03-29 11:58:58      阅读:18      评论:0      收藏:0      [点我收藏+]

有个人有这么个需求

https://www.modb.pro/issue/7326

OGG实时同步当源端字段值为1时,目标端该字段改为0 ,当源端字段为0或空值时,目标端该字段改为1,这个好通过OGG参数去实现吗?

测试如果是char类型字段可能存在null无法转换 ,varchar2 正常,可以使用如下设置进行参考。

 

test

SQL> desc test1
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 ID                                                 NUMBER(38)
 NAME                                               VARCHAR2(10)
SQL> insert into test1(id) values(7);
SQL> insert into test1 values(8,null);
SQL> insert into test1 values(9,1);
SQL> insert into test1 values(10,1);
SQL> insert into test1 values(11,0);

map test2.test1, target test2.test1,COLMAP(usedefaults,NAME=@EVAL(NAME=1,0,NAME=0,1,1));
        ID NAME
---------- ----------
         7 1
         8 1
         9 0
        10 0
        11 1
        
map test2.test1, target test2.test1,COLMAP(usedefaults,NAME=@EVAL(NAME=1,0,NAME=0,1,1));

map test2.test1, target test2.test1,COLMAP(usedefaults,NAME=@case(NAME,1,0,0,1,1));
SQL> insert into test1(id) values(12);
SQL> insert into test1 values(13,null);
SQL> insert into test1 values(14,1);
SQL> insert into test1 values(15,0);
        12 1
        13 1
        14 0
        15 1

 

OGG-字段符合特定条件,转换为某些特定字符,测试

原文:https://www.cnblogs.com/lvcha001/p/14591448.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!