oracle的select into问题
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(没有测试过)
为了避免错误,有几种方法可以借鉴:
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(没有测试过)