合并语句错误,想要更新几个表



合并语句显示错误:

MERGE INTO costing.table1 USING
(SELECT table1.ROWID row_id,
        M.STRPS_MATERIAL AS STRPS_MATERIAL
   FROM costing.table2 p
   JOIN costing.table1 M
     ON p.MATNR = M.MATNR
    AND p.WERKS = M.WERKS
    AND p.BESKZ = M.BESKZ
    AND p.SOBSL = M.SOBSL
  WHERE M.SOBSL = '30') src ON (table1.ROWID = src.row_id )
 WHEN MATCHED THEN
   UPDATE SET M.STRPS_MATERIAL = src.STRPS_MATERIAL;

SQL Error: ORA-00904: "table1"."ROWID": invalid identifier
00904. 00000 -  "%s: invalid identifier"

帮助我纠正查询,因为rowid不是table1中存在的列。

您可以尝试以下操作:

MERGE INTO costing.table1 USING
  (SELECT M.ROWID row_id,
  M.STRPS_MATERIAL AS STRPS_MATERIAL
  FROM costing.table2 p
 JOIN costing.table1 M
 ON p.MATNR                                           = M.MATNR
 AND p.WERKS                                          = M.WERKS
 AND p.BESKZ                                          = M.BESKZ
 AND p.SOBSL                                          = M.SOBSL
 WHERE M.SOBSL                                        = '30'
 ) src ON (costing.table1.ROWID = src.row_id )
 WHEN MATCHED THEN
 UPDATE SET M.STRPS_MATERIAL = src.STRPS_MATERIAL;

相关内容

  • 没有找到相关文章