oracle游标取数据是否显示打开游标

华而不实 华而不实 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

create or replace procedure test_cursor_proce
is
cursor test_cursor is select * from test_table;
test_record test_table%rowtype;
begin
--1.loop... fetch 游标必须手动显示open
loop
fetch test_cursor into test_record ;
dbms_output.put_line(test_record.id || test_record.name);--运行时报错
end loop;
end;


--2.for ... in 游标可以不用手动显示open
for test_cu in test_cursor loop
dbms_output.put_line(test_cu.id || test_cu.name);--运行时正常取数
end loop;

if test_cursor%isopen then
dbms_output.put_line('游标已打开。。。');
else
dbms_output.put_line('游标未打开。。。');
end if;
--输出结果为“游标未打开”


求大神对上述两种取数稍作解释。。尤其是for形式的取数,不太明了其原理,test_cu 是什么。。游标?但test_cu%notfound 报错。。。
...全文
评论 5
收藏 已收藏
分享
返回顶部
华而不实
Oracle 17,133 成员 55,258 内容