本帖最后由 mg122623 于 2010-05-27 20:55:32 编辑

解决方案 »

  1.   

    最好给个表结构和一些数据。A中只要有xh=userid就更新全部还是什么?
      

  2.   

    A  中 只有XH  这个字段   B 中有userid 和 ZT  两个字段只要 A中的XH 在 B表中存在的话 就更新 B表的字段ZT=2
      

  3.   

    update b
       set zt = 2
     where exists(select 1 from a where a.xh = b.userid);
      

  4.   

     
    codearts  写成 存储过程  谢谢
      

  5.   

    update B b set(zt = 2) where b.userid in (select xh from A)
      

  6.   

    create or replace procedure updateZT
    is
    begin
      update B b set zt='2' where b.userid in (select xh from A);
    commit;
    exception
    when others then
    rollback;
    end;
      

  7.   

    如果表比较大 建议 
    create or replace procedure text
    is
    begin execute immediate 'create table temp as
    select B.userid userid ,
           B.zt zt ,
           A.XH XH
    from  B,A
    WHERE B.USERID  = A.XH(+)';execute immediate 'truncate table B';
    INSERT INTO B
    SELECT userid ,
           CASE WHEN XH IS NULL THEN ZT ELSE '2' END 
            FROM TEMP;
    COMMIT;EXECUTE IMMEDIATE 'DROP TABLE TEMP';
    END TEXT;