假如我想对一条SQL语句进行一场处理
怎么使用?过多的用BEGIN   END。。发现会混乱

解决方案 »

  1.   

    declare
    v_a A.a%type;
    v_b B.b%type; 
    begin
    begin
    select a into v_a from A where 1>2; 
    Exception 
    when NO_DATA_FOUND then raise_application_error(-20001,'未找到产品');
    end;
    begin
    select b into v_b from B where 1>2; 
    Exception 
    when NO_DATA_FOUND then raise_application_error(-20001,'无此合同');
    end;
    end; 
    /
      

  2.   

    begin
      sql statement
    exception
      when ... then 
        sql statement
      when others then 
        sql statement
    end;
    基本都是类似与这样的SQL
      

  3.   

    對sql處理    基本都是檢查 是否執行吧?
    update delete?
    那就加sql%rowcount   然後if裡面 raise  exception就行了~剩下的就是上面哥們們寫的方式~