The following example demonstrates how to pass out a PL/SQL table in a stored procedure:
create or replace package test_pkg
is
type volume_type is table of number(6)
index by pls_integer;
end test_pkg;
/
create or replace procedure test_proc
(
p_times in pls_integer default 1,
p_vol out test_pkg.volume_type
)
is
begin
for i in 1 .. 10 loop
p_vol(i):= i * p_times;
end loop;
end test_proc;
/
declare
get_vol test_pkg.volume_type;
begin
test_proc(p_times => 10,
p_vol => get_vol);
for i in get_vol.FIRST .. get_vol.LAST loop
dbms_output.put_line(get_vol(i));
end loop;
end;
/
Here's the output:
10
20
30
40
50
60
70
80
90
100
全站熱搜