使用解码更新不起作用,为什么输入空数据?

时间:2019-05-27 06:41:04

标签: sql oracle

Traceback (most recent call last):
  File "/Users/sebastienchabrol/Documents/Cours de python/pendu/fonctions.py", line 6, in <module>
    listerecuperee=unpickler1.load()
_pickle.UnpicklingError: could not find MARK

如果update x1 a set (a.cd)= (select distinct(decode(b.cd1,null,a.cd,b.cd1)) from x2 b where b.nm(+)=a.nm and d.nm2(+)=a.nm2 数据是b.cd1,则null输入a.cd,但是我操作此sql,a.cd数据输入null,但是当我只操作子查询,所以效果很好,所以我不知道为什么会发生此问题

你能帮我吗?

1 个答案:

答案 0 :(得分:0)

这样说吧?

update x1 a
    set a.cd = (select b.cd1
                from x2 b
                where b.nm = a.nm and b.nm2 = a.nm2
--------------------------------------^ assume you intend b here
               )
    where (select b.cd1
           from x2 b
           where b.nm = a.nm and b.nm2 = a.nm2
          ) is not null;

也就是说,仅更新值不是NULL的行。