--创建dblink
CREATE DATABASE LINK TBWX
CONNECT TO HUASHENGFORMAL IDENTIFIED BY "hs666"
USING '116.62.105.113/orcl';
--测试dblink
select * from WEIXINCONFIG@TBWX;
--创建同步存储过程
create or replace procedure TBWX
is
begin
merge into WEIXINCONFIG@TBWX b using WEIXINCONFIG c on (b.WEIXIN_ID=c.WEIXIN_ID)
--从center将表merge到branch,同步的依据是两个表的pk
when matched then update set
b.APPID=c.APPID,
b.APPSECRET=c.APPSECRET,
b.ACCESSTOKEN=c.ACCESSTOKEN,
b.JSAPITICKET=c.JSAPITICKET,
b.TOKEN=c.TOKEN,
b.AESKEY=c.AESKEY,
b.TEMPLATE=c.TEMPLATE,
b.TEMPLATE2=c.TEMPLATE2,
b.WEIXIN_BUILDDATE=c.WEIXIN_BUILDDATE,
b.TEMPLATE3=c.TEMPLATE3
--如果pk值是相同则将指定表的值更新到目标表
when not matched then
--如果pk值不一至,则将源表中的数据整条插入到目标表中
insert values (
c.WEIXIN_ID,
c.APPID,
c.APPSECRET,
c.ACCESSTOKEN,
c.JSAPITICKET,
c.TOKEN,
c.AESKEY,
c.TEMPLATE,
c.TEMPLATE2,
c.WEIXIN_BUILDDATE,
c.TEMPLATE3
);
end;
--创建job定时器
declare
jobno number;
BEGIN
DBMS_JOB.SUBMIT(jobno,
'TBWX;',
SYSDATE,
'TRUNC(sysdate,''mi'') + 1 / (24*60)');
End;