-
前言
使用table函数,可在不建表的情况下,可与其他处理逻辑的fuction相结合,达到完成运算后再展现数据集的效果。
现阶段,本人主要将此用在接口、报表两个方面。
create or replace type t_test as object (
id number,
time date,
data varchar2(60)
);
create or replace type t_test_tb as table of t_test;
create or replace function f_test_array(n in number default null) return t_test_tb as
t_array t_test_tb := t_test_tb();
begin
for i in 1..nvl(n,100) loop
t_array.extend();
t_array(t_array.count) := t_test(i,sysdate,'mi'||i);
end loop;
return t_array;
end;
select * from table(f_test_array(10)); select * from the(select f_test_array(10) from dual);