【发布时间】:2020-10-13 16:53:29
【问题描述】:
我想运行这种multi-column correlated update:
UPDATE t1 t1_alias
SET (table_name, tablespace_name) = (
SELECT table_name, tablespace_name
FROM t2 t2_alias
WHERE t1_alias.table_name = t2_alias.table_name
);
但我的尝试:
update customer up
set (customer_name, account, active) = (
select tmp.name, tmp.account, case when tmp.active = 'Yes' then 1 else 0 end
from customer_temp tmp
where up.agent = substr(tmp.agent, -4) and up.customer_code = tmp.code
);
...抛出:
ORA-01407: cannot update ("FOO"."CUSTOMER"."CUSTOMER_NAME") to NULL
源表customer_temp 没有空值,所以我一定是匹配错误。我的错误或误解是什么?
【问题讨论】:
-
似乎
foo.customer.customer_name不是空列。并且您的select语句未匹配任何结果或其tmp.name is null。
标签: oracle select oracle11g sql-update subquery