MERGE INTO table_1 a
USING
(SELECT * from table_2) b ON ( a.row_id = b.row_id and a.in_correct IS NULL)
WHEN MATCHED THEN UPDATE SET a.in_correct = 'Y';
在上面的查询中ORA-38104:ON子句中引用的列无法更新。
我已经坐了几个小时来解决这个问题。
我已经确定问题是字段in_correct。
此字段“in_correct”不能同时放入ON子句和SET之后。但为了满足我的标准,我别无选择。
请帮帮我
答案 0 :(得分:1)
MERGE INTO table_1 a USING
(SELECT * from table_2) b
ON ( a.row_id = b.row_id)
WHEN MATCHED THEN UPDATE
SET a.in_correct = NVL(in_correct, 'Y');
更新:
更“通用”的命令(对于非空值):
MERGE INTO table_1 a USING
(SELECT * from table_2) b
ON ( a.row_id = b.row_id)
WHEN MATCHED THEN UPDATE
SET a.in_correct = case
when in_correct = 'valuetobereplaced' then 'Y';
else in_correct;
end;