==怎么判断一个游标中有没有记录?==

lz_0618 2002-04-16 10:11:47
在存储过程中创建了游标,怎么判断有无记录?
...全文
205 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
lz_0618 2002-04-17
  • 打赏
  • 举报
回复
终于在PL/SQL的帮助中找到了,很简单,是MyCur%RowCount
ykliu1 2002-04-16
  • 打赏
  • 举报
回复
declare
v_f1 t1.f1%type;
v_f2 t1.f2%type;
cursor aa is select f1,f2 from t1;
begin
open aa;
loop;
fetch aa into v_f1,v_f2;
exit when aa%notfound;
end loop;
close aa;
end;

游标属性:
%notfound,%found,%rowcount,%isopen....
jlandzpa 2002-04-16
  • 打赏
  • 举报
回复
笨方法:select count(*) ......
lz_0618 2002-04-16
  • 打赏
  • 举报
回复
没有fetch cur into ...;能行吗?
hanps 2002-04-16
  • 打赏
  • 举报
回复
if cur%found then
smartdonkey 2002-04-16
  • 打赏
  • 举报
回复
判断有记录:
if mycursor%found then
--处理
end if;

判断无记录:
if mycursor%notfound then
--处理
end if;
lyxinfo 2002-04-16
  • 打赏
  • 举报
回复
呵呵,没有取数据。
open cur;
fetch cur into ...;
if cur%found then
...
lyxinfo 2002-04-16
  • 打赏
  • 举报
回复
open cur;
if cur%found then
...
jaguarcts 2002-04-16
  • 打赏
  • 举报
回复
gz
haode 2002-04-16
  • 打赏
  • 举报
回复
用%FOUND和%NOTFOUND检验游标成功与否;

在用循环检索游标的时候,检索出的纪录总行数保存在变量%ROWCOUNT里边
lz_0618 2002-04-16
  • 打赏
  • 举报
回复
RecNum int;
。。。
select count(*) into RecNum from TestTab where (User_ID = AUserID) and (User_Name=AUserName);
数据库中没有记录时,RecNum竟然会返回1????
在Sql*plus正常!!!
select count(*) from TestTab where (User_ID = AUserID) and (User_Name=AUserName);

lz_0618 2002-04-16
  • 打赏
  • 举报
回复
游标属性:
%notfound,%found,%rowcount,%isopen....

那只是在Fetch后才能用啊!!!!!

countach 2002-04-16
  • 打赏
  • 举报
回复
if cursorname%rowcount <> 0 then
...

2,596

社区成员

发帖
与我相关
我的任务
社区描述
Sybase相关技术讨论区
社区管理员
  • Sybase社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧