日期:2014-05-17  浏览次数:21260 次

merge中using能不能用dblink
如题,我在写sql的时候用merge时在using里面使用了dblink,oracle报错提示缺失on关键字,求大神指导
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;
oracel?merge?dblink

------解决方案--------------------
on后面的条件用()括起来
------解决方案--------------------
引用:
on后面的条件用()括起来


官方参考文档:MERGE