我需要在特定列中更新几个值。我制作该列的副本,然后更新新列中的值。但我的合并代码使所有值为null,不需要进行任何更改。任何人都可以帮助我
UPDATE L04_A_AVOX_DATA
SET NIK_Regulatory_Classifciation = Regulatory_Classification;
MERGE INTO L04_A_AVOX_DATA n
USING (SELECT NIK_SEQ_AVOX, new_value
FROM (SELECT *
FROM L04_A_AVOX_DATA
LEFT OUTER JOIN
(SELECT old_value, new_value
FROM TRANSFORMATION_DATA_ALL
WHERE column_identifier =
'Regulatory_Classification'
AND Source_identifier = 'Avox')
ON Regulatory_Classification = old_value)) o
ON (n.NIK_SEQ_AVOX = o.NIK_SEQ_AVOX)
WHEN MATCHED
THEN
UPDATE SET NIK_Regulatory_Classifciation = o.new_value;
答案 0 :(得分:0)
子查询
"SELECT * FROM L04_A_AVOX_DATA LEFT JOIN <doesn't matter> ON <doesn't matter>"
始终至少返回整个L04_A_AVOX_DATA。这就是为什么当你制作MERGE时所有行都会更新(每行总是匹配)
此外,如果USING子句中使用的视图具有o.NIK_SEQ_AVOX(MERGE是确定性的),则合并可能会失败