我有像
这样的更新查询update dedupctntest a set a.city = case when exists(
select b.shortname from DEDUPADDRESSDICT where lower(a.city) =lower(b.shortname) and rownum = 1) b then
b.fullname else a.city end;
但会产生missing keyword
错误
任何人都能说出错误吗?
答案 0 :(得分:5)
您不能在其范围之外引用b.fullname,它位于exists()子句中。
也许这可以满足您的需求:
update dedupctntest a
set a.city = coalesce
( ( select b.fullname
from DEDUPADDRESSDICT
where lower(a.city) = lower(b.shortname)
and rownum = 1
)
, a.city
);
即。如果来自DEDUPADDRESSDICT的查询返回一个非null的全名,则使用它,否则使用a.city。请注意,如果DEDUPADDRESSDICT中有一行使用null全名,则将使用a.city。
答案 1 :(得分:0)
尝试以下内容
update dedupctntest a set a.city = case when exists(
select * from DEDUPADDRESSDICT where lower(a.city) =lower(b.shortname) and rownum = 1) b then
(select fullname form DEDUPADDRESSDICT where lower(a.city) =lower(b.shortname) and rownum = 1)
b.fullname else a.city end;