日期:2014-05-16  浏览次数:20351 次

函数返回数组的例子

转载自:http://www.cnblogs.com/aspsmile/category/186171.html

原文位于:http://www.itpub.net/viewthread.php?tid=610297&extra=page%3D2%26amp%3Bfilter%3Ddigest&page=2

create or replace type t_ret_table is table of varchar2(20);

create or replace function f_test(var_num in integer) return t_ret_table is
var_out t_ret_table;
begin
? ? ? ? var_out := t_ret_table();
? ? ? ? var_out.extend(var_num);
? ? ? ? for i in 1..var_num loop
? ? ? ? ? ? ? ? var_out(i) := i;
? ? ? ? end loop;
? ? ? ? return var_out;
end f_test;
/
set serverout on
declare
aa t_ret_table;
begin
aa := f_test(10);
for i in 1..aa.count loop
? ? ? ? dbms_output.put_line(aa(i));
end loop;
end;
/