pipelined 函数

pipelined表函数用于返回行结果集。

 

下面是一个例子:

 

CREATE PACKAGE pkg1 AS
TYPE numset_t IS TABLE OF NUMBER;
FUNCTION f1(x NUMBER) RETURN numset_t PIPELINED;
END pkg1;
/


CREATE PACKAGE BODY pkg1 AS
-- FUNCTION f1 returns a collection of elements (1,2,3,... x)
FUNCTION f1(x NUMBER) RETURN numset_t PIPELINED IS
BEGIN
FOR i IN 1..x LOOP
PIPE ROW(i);
END LOOP;
RETURN;
END;
END pkg1;
/


-- pipelined function is used in FROM clause of SELECT statement
SELECT * FROM TABLE(pkg1.f1(5));

 

执行结果是:

COLUMN_VALUE
------------
           1
           2
           3
           4
           5

 

参考文献:

《Oracle Database PLSQL User's Guide and Reference 10g Release 2.pdf》

你可能感兴趣的:(oracle,function,user,table,database,reference)