17,140
社区成员




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;
--输出结果为“游标未打开”