An example of a pipelined table function. : PIPELINED « Stored Procedure Function « Oracle PL / SQL






An example of a pipelined table function.

  
SQL>
SQL>
SQL> CREATE TYPE MyType AS OBJECT (
  2    field1 NUMBER,
  3    field2 VARCHAR2(50));
  4  /


SQL>
SQL> CREATE or replace TYPE MyTypeList AS TABLE OF MyType;
  2  /

Type created.

SQL>
SQL> CREATE OR REPLACE FUNCTION PipelineMe
  2    RETURN MyTypeList PIPELINED AS
  3    v_MyType MyType;
  4  BEGIN
  5    FOR v_Count IN 1..20 LOOP
  6      v_MyType := MyType(v_Count, 'Row ' || v_Count);
  7      PIPE ROW(v_MyType);
  8    END LOOP;
  9    RETURN;
 10  END PipelineMe;
 11  /

Function created.

SQL>
SQL> SELECT *
  2    FROM TABLE(PipelineMe);

    FIELD1 FIELD2
---------- --------------------------------------------------
         1 Row 1
         2 Row 2
         3 Row 3
         4 Row 4
         5 Row 5
         6 Row 6
         7 Row 7
         8 Row 8
         9 Row 9
        10 Row 10
        11 Row 11
        12 Row 12
        13 Row 13
        14 Row 14
        15 Row 15
        16 Row 16
        17 Row 17
        18 Row 18
        19 Row 19
        20 Row 20

20 rows selected.

SQL>
SQL> DROP TYPE MyType;


SQL>
SQL>

   
  








Related examples in the same category

1.Using a pipelined table function.
2.pipelined returning value and table() function