日期:2014-05-17 浏览次数:20887 次
MERGE INTO L2_TB S
USING TEST.TB_HOS@CLOUD.WORLD Y
ON S.ID=(CASE WHEN TRIM(Y.JLHH) IS NOT NULL THEN Y.LSH||LPAD(Y.JLHH,6,'0')
ELSE Y.LSH||'000000' END)
WHEN MATCHED THEN
UPDATE SET(ZHH,KH,XM,SFZH,JSRQSJ,JYRQ,DIC_ID,DIC_MC,KSBM,KSMC,YSGH,YSXM,JSLXBZ)=
(SELECT B.ZHH,A.KH,B.XM,B.SFZH,A.JSRQSJ,A.JYRQ,A.DIC_ID,C.NAME,A.KSBM,A.KSMC,A.YSGH,A.YSXM,A.JSLXBZ
FROM TEST.TB_HOS@CLOUD.WORLD A,TEST.TB_ZH@CLOUD.WORLD B,TEST.TB_DIC@CLOUD.WORLD C
WHERE A.KH=B.KH AND A.DIC_ID=C.ID AND LENGTH(A.KH)=9 AND SUBSTR(A.LSH,3,4)='0101';)
WHEN NOT MATCHED THEN
INSERT(ZHH,KH,XM,SFZH,JSRQSJ,JYRQ,DIC_ID,JGMC,KSBM,KSMC,YSGH,YSXM,JSLXBZ)
SELECT B.ZHH,A.KH,B.XM,B.SFZH,A.JSRQSJ,A.JYRQ,A.DIC_ID,C.NAME,A.KSBM,A.KSMC,A.YSGH,A.YSXM,A.JSLXBZ
FROM TEST.TB_HOS@CLOUD.WORLD A,TEST.TB_ZH@CLOUD.WORLD B,TEST.TB_DIC@CLOUD.WORLD C
WHERE A.KH=B.KH AND A.DIC_ID=C.ID AND LENGTH(A.KH)=9;