我想在一个循环里边进行select into 操作,对每一个select into都捕获了no_data_found异常,请问还会抛出其他异常吗?我在循环结束的时候(end if前边)写了 exception when others then 进行捕获异常。

解决方案 »

  1.   

    select into都捕获了no_data_found异常,请问还会抛出其他异常吗?
    当然会啊,例如 SELECT COL1/0 INTO V_COL1 FROM TAB1;
    这样就会抛出除0异常
      

  2.   

    select into 最常见的两个异常:NO_DATA_FOUND(无数据)和too many rows(超过一行数据)。
    要保证代码逻辑,用 begin end 把它包起来,里面用 exception when others then捕获所有异常进行处理。
    for .... loop
       ....
       begin
           select .. into ...
           exception when others then
           ...
       end
    ....
    end loop;
      

  3.   

    异常肯定会很多的,有些异常只有发生了你才知道,否则的话你永远不知道,所以有必要写个when others then 
      

  4.   

    写了异常报错代码可以一直执行下去,否则就报bug,终止执行