1.使用select into

begin
  select dno into v_dno from tbl where xxx.
exception
  when no_data_found then
  --无数据
end;

  

2.游标fetch

open mycursor;
fetch mycursor into rec;
  if mycursor%notfound then
    --无数据
  end if;
close mycursor;

3.游标%rowcount属性判断

open mycursor;
  if mycursor%rowcount =0 then
    --无数据
  end if;
 close mycursor;

注意:打开游标之后不fetch,就判断游标%notfound是不行的。不论有没有数据都会返回true。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-11
  • 2021-12-27
  • 2022-12-23
  • 2022-01-24
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-02-14
  • 2021-09-26
  • 2022-12-23
  • 2022-02-02
  • 2022-12-23
相关资源
相似解决方案