存储过程使用游标和索引

create or replace procedure cursor_emp_ename is

--使用游标和索引显示员工名称
type emp_table is table of varchar2(10)
index by binary_integer;
emplist emp_table;
cursor empcursor
is select ename from emp;

begin
if not empcursor%isopen --如果游标没有打开,打开游标
then
open empcursor;
end if;
fetch empcursor
bulk collect into emplist; --从游标提取所有员工名称 存入索引中
for i in 1..emplist.count --for循环显示所欲员工的名称
loop
dbms_output.put_line('员工名称'||emplist(i));
end loop;
close empcursor;
end cursor_emp_ename;

原文地址:https://www.cnblogs.com/shejiewei/p/9869880.html