日期:2014-05-17 浏览次数:21186 次
--你想用 table() 这种方式查询数据,你的函数不能是普通函数。 create table tb1(k number, v varchar2(10)); insert into tb1(k, v) values(100,'aaa'); insert into tb1(k, v) values(200,'bbb'); insert into tb1(k, v) values(200,'ccc'); select * from tb1; create type row_type1 as object(k number, v varchar2(10)); create type table_type1 as table of row_type1; create or replace function fun1 return table_type1 pipelined as v row_type1; begin for myrow in (select k, v from tb1) loop v := row_type1(myrow.k, myrow.v); pipe row (v); end loop; return; end; select * from table(fun1);