我正在尝试从下表更新BUNDLE_NAME, 我的查询是:
MERGE INTO SOURCE S USING
(SELECT 'MANIFEST_ID' KEY,'CART' BUNDLE_NAME FROM DUAL) D
ON(S.KEY = D.KEY AND S.BUNDLE_NAME = D.BUNDLE_NAME)
WHEN MATCHED THEN UPDATE
SET BUNDLE_NAME = 'EPI';
但是它给了我以下错误:
错误报告 - SQL错误:ORA-38104:无法更新ON子句中引用的列:“S”。“BUNDLE_NAME” 38104. 00000 - “无法更新ON子句中引用的列:%s” *原因:UPDATE SET的LHS包含ON子句**
中引用的列
- 我的要求是我只想使用merge语句进行更新 -
答案 0 :(得分:1)
There are a few possible workarounds which can be used to outsmart the parser,至少直到Oracle 18c。其中之一是使用附加的伪列将谓词包装在行值表达式谓词中:
MERGE INTO SOURCE S USING
(SELECT 'MANIFEST_ID' KEY,'CART' BUNDLE_NAME FROM DUAL) D
ON(S.KEY = D.KEY AND (S.BUNDLE_NAME, 'dummy') = ((D.BUNDLE_NAME, 'dummy')))
WHEN MATCHED THEN UPDATE
SET BUNDLE_NAME = 'EPI';