oracle的管道也可以返回集合类型,跟游标类似
CREATE TYPE my_type AS OBJECT (
field1 NUMBER,
field2 VARCHAR2 (50)
);
CREATE TYPE
my_typelist AS TABLE OF my_type;
CREATE OR REPLACE FUNCTION
pipelineme
RETURN my_typelist PIPELINED IS
--定义自己的类型--
v_mytype
my_type;
BEGIN
FOR v_count IN 1 .. 20 LOOP
v_mytype :=
my_type(v_count, 'Row ' || v_count);
PIPE ROW(v_mytype);
END
LOOP;
--此处一定要返回空
RETURN;
END pipelineme;
--测试--
select * from
table(pipelineme);