在表A中我要判断属性a和b的值是否相等,如果相等执行表B的更新,如果不等要提示表B更新失败
这样的语句怎样在sqlplus中实现呢?

解决方案 »

  1.   

    megert into a 
    using b on (a.id=b.id)
    when matched update
    when not matched insert 这样可以使用,查查看
      

  2.   

    如果相等执行表B的更新,如果不等要提示表B更新失败 
    楼主的要求,megert实现不了,只能用存储过程
      

  3.   

    -- Created on 2008-7-4 by PP 
    declare 
      -- Local variables here
      cursor a_cursor is
             select a,b from A;
    begin
      -- Test statements here
      for A_record in a_cursor loop
          if A_record.a=A_record.b then
             update B set c='' where a=A_record.a and b=A_record.b;
             dbms_output.put_line('表B更新成功');
          else
             dbms_output.put_line('表B更新失败');
          end if;
      end loop;
      exception
          when sql%notfound then
               dbms_output.put_line('表B更新失败');
    end;
    楼主看看,是不是这样的?