合并为当Matched子句不起作用时。

2020-08-27 13:45发布

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


合并到" TESTDB"中。" Customers_2"" M"使用(选择" T"。"地址"," T"。"城市"," T"。" CompanyName"," T"。" ContactName", " T"。" ContactTitle"," T"。"国家"," T"。"客户ID"," T"。"传真"," T"。"电话"," T"。"邮政编码"," T "。" Region" FROM" Scd_5492_ASTWK_2"" T")T ON(" M"。" CustomerID" =" T"。" CustomerID")匹配时(MAP(" T"。"地址"," M"。 "地址",0、1)= 1或MAP(" T"。"城市"," M"。"城市",0、1)= 1或MAP(" T"。"公司名称"," M"。 " CompanyName",0,1)= 1 OR MAP(" T"。" ContactName"," M"。" ContactName",0,1)= 1 OR MAP(" T"。" ContactTitle"," M"。 " ContactTitle",0,1)= 1 OR MAP(" T"。"国家"," M"。" Country",0,1)= 1 OR MAP(" T"。"传真"," M"。 " Fax",0,1)= 1 OR MAP(" T"。" Phone"," M"。" Phone",0,1)= 1 OR MAP(" T"。" PostalCode"," M"。 " PostalCode",0,1)= 1或MAP(" T"。" Region"," M"。" Region",0,1)= 1)然后更新集" Address" =" T"。" Address" ," City" =" T"。" City"," CompanyName" =" T"。" CompanyName"," ContactName" =" T"。" ContactName"," ContactTitle" =" T"。" ContactTitle"," 国家" =" T"。"国家","传真" =" T"。"传真","电话" =" T"。"电话"," PostalCode" =" T"。" PostalCode"," Region" =" T"。" Region";

嗨,我有一个查询,给出以下错误。

sql语法错误:必须存在WHEN MATCHED子句或WHEN NOT MATCHED子句中的至少一个。:第1行col 1(在pos 0)

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


合并到" TESTDB"中。" Customers_2"" M"使用(选择" T"。"地址"," T"。"城市"," T"。" CompanyName"," T"。" ContactName", " T"。" ContactTitle"," T"。"国家"," T"。"客户ID"," T"。"传真"," T"。"电话"," T"。"邮政编码"," T "。" Region" FROM" Scd_5492_ASTWK_2"" T")T ON(" M"。" CustomerID" =" T"。" CustomerID")匹配时(MAP(" T"。"地址"," M"。 "地址",0、1)= 1或MAP(" T"。"城市"," M"。"城市",0、1)= 1或MAP(" T"。"公司名称"," M"。 " CompanyName",0,1)= 1 OR MAP(" T"。" ContactName"," M"。" ContactName",0,1)= 1 OR MAP(" T"。" ContactTitle"," M"。 " ContactTitle",0,1)= 1 OR MAP(" T"。"国家"," M"。" Country",0,1)= 1 OR MAP(" T"。"传真"," M"。 " Fax",0,1)= 1 OR MAP(" T"。" Phone"," M"。" Phone",0,1)= 1 OR MAP(" T"。" PostalCode"," M"。 " PostalCode",0,1)= 1或MAP(" T"。" Region"," M"。" Region",0,1)= 1)然后更新集" Address" =" T"。" Address" ," City" =" T"。" City"," CompanyName" =" T"。" CompanyName"," ContactName" =" T"。" ContactName"," ContactTitle" =" T"。" ContactTitle"," 国家" =" T"。"国家","传真" =" T"。"传真","电话" =" T"。"电话"," PostalCode" =" T"。" PostalCode"," Region" =" T"。" Region";

嗨,我有一个查询,给出以下错误。

sql语法错误:必须存在WHEN MATCHED子句或WHEN NOT MATCHED子句中的至少一个。:第1行col 1(在pos 0)

付费偷看设置
发送
1条回答
jovirus
1楼-- · 2020-08-27 14:39

没有表来运行您的语句,我无法在HANA 2 SP04上重现此错误。

但是,我怀疑可能有悬挂的支架或类似的东西。 除了语法检查器之外,我知道处理此类问题的最好方法就是使该语句更易于阅读。

当您摆脱了不必要的引号(不是表别名时,请继续。) )和检查地址字段是否不同的超级怪异方法(为什么不使用相等条件?),您可以得到如下语句:

 MERGE INTO
         " TESTDB"。" Customers_2" M
 使用方式
     (选择
         "顾客ID",
         "地址","城市","公司名称",
         " ContactName"," ContactTitle","国家",
         "传真","电话","邮政编码","区域"
     来自" Scd_5492_ASTWK_2")T
     开(M."客户ID" = T."客户ID")
     配对时
         AND(
                 (T."地址",T."城市",T." CompanyName"
                 ,T." ContactName",T." ContactTitle",T." Country"
                 ,T。"传真",T。"电话",T。"邮政编码",T。"地区")
            
             !=(M."地址",M."城市",M."公司名称"
                 ,M." ContactName",M." ContactTitle",M." Country"
                 ,M。"传真",M。"电话",M。"邮政编码"," M"。"区域")
              )

         然后
 更新集
         M."地址" = T."地址",
         M."城市" = T."城市",
         M." CompanyName" = T." CompanyName",
         M." ContactName" = T." ContactName",
         M." ContactTitle" = T." ContactTitle",
         M."国家" = T."国家",
         M."传真" = T."传真",
         M."电话" = T."电话",
         M." PostalCode" = T." PostalCode",
         M." Region" = T." Region";
 

不确定您的身份,但是对我来说,这更容易阅读。

此外,这种形式在我的测试实例(由伪表/数据组成)上也可以正常工作。

一周热门 更多>