您的位置:首页 > 数据库 > Oracle

Oracle判断数据是否存在(使用游标判断需要注意的问题)

2013-11-19 17:36 645 查看
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。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐