如果没有找到值,你就把这个字段变成NULL了。要想达到目的,用NVL判断一下看看吧。

解决方案 »

  1.   

    参考一下下面的两种更新update tset ( x,y,z) 
           = ( select x,y,z
               from t1
               where t.x ==t1.x)
       where exists 
    ( select x,y,z
               from t1
               where t.x ==t1.x)[email protected]> update
      2    ( select columnName, value      -- 不能用 col 的别名 因为外部的看不到内部的view
      3        from name, lookup           -- 如 value v 下面的set columnName=v
      4       where name.keyname = lookup.keyname
      5         and lookup.otherColumn = :other_value )
      6     set columnName = value
      7  /
      

  2.   

    因为你的子查询返回了空值。用nvl函数处理一下就可以了。试试下面的:
    update scm.inventory_batch a
           set a.invb_valid_date=(select nvl(min(b.date_ok),a.invb_valid_date)
                                           from scm2004.batch_num b 
                                           where a.invb_pro_id=b.spcode
                                                 and a.invb_batch_num=b.batch_num
                                           group by b.spcode)
      

  3.   

    最好在后面再加上where条件,否则update会把你的数据改的一塌糊涂。
    update scm.inventory_batch a
           set a.invb_valid_date=(select min(b.date_ok)
                                           from scm2004.batch_num b 
                                           where a.invb_pro_id=b.spcode
                                                 and a.invb_batch_num=b.batch_num
                                           group by b.spcode)
    where exists (select 1 
                    from scm2004.batch_num b 
                   where a.invb_pro_id=b.spcode
                     and a.invb_batch_num=b.batch_num)
      

  4.   

    to wl3721() ( ) 
    你的方法不行,还是被置空。
      

  5.   

    同意ronerlu() 的說法,我以前也碰到這樣的問題!
    對於要UPDATE的表你一定要明確UPDATE所涉及的數據的條件。
    更改如下:
    update scm.inventory_batch a
       set a.invb_valid_date=
          (
           select min(b.date_ok)
           from   scm2004.batch_num b 
           where  a.invb_pro_id=b.spcode
           and    a.invb_batch_num=b.batch_num
           group by b.spcode
          )
    where (a.invb_pro_id,a.invb_batch_num) in 
         (
          select distinct b.spcode,b.batch_num
          from   scm2004.batch_num b 
         )
      

  6.   

    update scm.inventory_batch a
       set a.invb_valid_date=
          (
           select min(b.date_ok)
           from   scm2004.batch_num b 
           where  a.invb_pro_id=b.spcode
           and    a.invb_batch_num=b.batch_num
           group by b.spcode
          )
    where  exists
          (
           select 'x' from scm2004.batch_num b    
           where  a.invb_pro_id=b.spcode
           and    a.invb_batch_num=b.batch_num
          )
      

  7.   

    希望有用:没有备份、只有归档日志,如何恢复数据文件?  
    系统环境: 
    1、操作系统:Windows 2000 Server,机器内存128M
    2、数据库: Oracle 8i R2 (8.1.6) for NT 企业版
    3、安装路径:C:\ORACLE模拟现象: 可通过重建数据文件来恢复,前提是归档日志文件保存完整先将数据库设置为归档模式SQL*Plusconn system/manager--创建实验表空间
    create tablespace test datafile
    'c:\test.ora' size 5M
    AUTOEXTEND ON NEXT 1M MAXSIZE UNLIMITED
    default storage (initial 128K next 1M pctincrease 0)
    /--创建实验用户
      drop user test cascade;
    create user test identified by test default tablespace test;
    grant connect,resource to test;
    conn test/testcreate table a(a number);
    insert into a values(1);
    insert into a select * from a; --反复插入,达到100万条
    commit;--关闭数据库
    SVRMGR> connect internal
    SVRMGR> alter system switch logfile; --强制归档
    SVRMGR> alter system switch logfile;
    SVRMGR> alter system switch logfile;
    SVRMGR> shutdown--操作系统下删除test.ora文件--重新启动数据库
    SVRMGR> connect internal
    SVRMGR> startup这时,可以mount上,但无法打开,因为数据文件test.ora不存在,
    显示错误如下:ORA-01157: ????/?????? 8 - ??? DBWR ????
    ORA-01110: ???? 8: 'C:\TEST.ORA'SVRMGR> connect internal
    SVRMGR> startup mount
    SVRMGR> alter database create datafile 'c:\test.ora';
    SVRMGR> set autorecovery on
    SVRMGR> recover datafile 'c:\test.ora';
    SVRMGR> alter database open;conn test/test
    select count(*) from a; --数据又恢复到100万条--删除实验表空间
    conn system/manager
    alter tablespace test offline;
    drop tablespace test INCLUDING CONTENTS;
    drop user test;
    --如果是非归档模式,也可以运用以上方法,
    --前提是:输入记录所占空间的大小不超过所有联机日志文件的大小
    --即:用联机日志文件来恢复 
      

  8.   

    update scm.inventory_batch a
           set a.invb_valid_date=(select min(b.date_ok)
                                           from scm2004.batch_num b 
                                           where a.invb_pro_id=b.spcode
                                                 and a.invb_batch_num=b.batch_num
                                           group by b.spcode)
    where (select count(1) from scm2004.batch_num c where a.invb_pro_id=c.spcode and a.invb_batch_num=c.batch_num) > 0