update test
    set a='0002', b=decode(b, '0001', '0002', b)
    where a='0001' and (b='0001' or b is null);

解决方案 »

  1.   

    SQL> select * from test;A          B
    ---------- ----------
    0001       0001
    0001
    SQL> update test set a=decode(a||'-'||b,'0001-0001','0002','0001-','0002',a),
      2  b=decode(a||'-'||b,'0001-0001','0002',b);已更新3行。SQL> select * from test;A          B
    ---------- ----------
    0002       0002
    0002
    SQL>
      

  2.   

    update test set 
        A = decode(A,'0001','0002',A),
        B = decode(B,'0001','0002',B)
    where
        A = '0001' and (B = '0001' or B is null)
      

  3.   

    bzszp(SongZip)大侠真是个天才,构思太巧妙了!
      

  4.   

    update test set b='0002' where b='0001' and a='0001';
    update test set a='0002' where a='0001';