Skip to Main Content

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Chaitanya.

Asked: June 08, 2017 - 8:01 am UTC

Last updated: June 09, 2017 - 2:40 am UTC

Version: 11g

Viewed 1000+ times

You Asked

Hi Tom,
Good Day!
I have some doubts on pipeline functions.I created pipeline function in Package.
i need to declare types within package to return a pipeline function.
is possible to create objects in package to return a pipeline function
is possible to create synonym for pipelined functions to call package and pipeline fucntion from another database


Thank you

and Connor said...

In 11g, you need the types separately


SQL> create or replace type myobj as object ( x int, y int );
  2  /

Type created.

SQL> create or replace type mylist is table of myobj;
  2  /

Type created.

SQL>
SQL> create or replace package pkg is
  2    function f return mylist pipelined;
  3  end;
  4  /

Package created.

SQL> create or replace
  2  package body pkg is
  3    function f return mylist pipelined is
  4    begin
  5      for i in 1 .. 10 loop
  6        pipe row ( myobj (i,i+1));
  7      end loop;
  8    end;
  9  end;
 10  /

Package body created.

SQL>
SQL> select * from table(pkg.f);

         X          Y
---------- ----------
         1          2
         2          3
         3          4
         4          5
         5          6
         6          7
         7          8
         8          9
         9         10
        10         11

10 rows selected.

SQL>
SQL>


In 12c, this restriction is lifted.

Is this answer out of date? If it is, please let us know via a Comment

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library