【发布时间】:2021-11-08 17:09:33
【问题描述】:
如何通过创建自己的包中使用的相同集合类型的集合来调用包中的函数?我们可以使用我们自己创建的集合来调用包中的函数吗?调用函数时出错。
create or replace package pk
is
type e_list is table of emp%rowtype index by pls_integer;
function pro1 return e_list;
end;
create or replace package body pk
is
x number;
function pro1 return e_list
is
v_emp e_list;
begin
for x in 100..110 loop
select * into v_emp(x) from employees where employee_id=x;
end loop;
return v_emp;
end;
end;
调用函数检查下面的代码。
declare
type p_list is table of emp%rowtype index by pls_integer;
r_cur p_list;
x number;
begin
r_cur:=pk.pro1;
x:=r_cur.first;
for i in 1..10 loop
dbms_output.put_line(r_cur(x).salary);
x:=r_cur.next(x);
end loop;
end;
【问题讨论】: