oracle的select into在没有查到结果的时候,不会返回null,而是返回一个NO_DATA_FOUND的错误。
为了避免错误,有几种方法可以借鉴:
1. 在into之前先count一下查询到的结果,如果等于1,然后再into数据。(得执行2遍select)
2.select min(A.col) into v_a from A
3.begin  
      ...  
      select   ..   into   ..   from   ..;  
      exception  
          when   no_data_found   then  
              ....;  
   
      ...  
  end;
4.使用cursor(没有测试过)

相关文章:

  • 2022-12-23
  • 2021-11-11
  • 2022-12-23
  • 2022-12-23
  • 2021-06-05
  • 2021-09-23
  • 2022-01-18
猜你喜欢
  • 2021-09-23
  • 2021-11-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案