Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: pipelined functions and recursive mechanism

Re: pipelined functions and recursive mechanism

From: Billy <vslabs_at_onwe.co.za>
Date: 19 Aug 2005 04:03:08 -0700
Message-ID: <1124449388.358121.184780@z14g2000cwz.googlegroups.com>


Umbi wrote:

> I have a question about pipelined functions. I want to write a
> recursive functions that should return some records. I also would like
> to write it as a pipelined functions but it doesn't work. Has someone
> an example or a link for me? I succeeded to write it in PL/SQL as a
> package with global variables but it is not what I wanted to do...

I doubt that this will work as pipelined functions... It does work with normal collections as the following example shows.

==
SQL> create or replace type TFooNumbers as table of number;   2 /

Type created.

SQL> create or replace function fooMe( level integer ) return TFooNumbers is
  2 f TFooNumbers;
  3 begin

  4          if level < 1 then
  5                  f := TFooNumbers( level );
  6          else
  7                  f := fooMe( level - 1 );
  8                  f.Extend(1);
  9                  f( f.Count ) := level;
 10          end if;
 11
 12          return( f );

 13 end;
 14 /

Function created.

SQL> select * from TABLE(fooMe(10));

COLUMN_VALUE


           0
           1
           2
           3
           4
           5
           6
           7
           8
           9
          10

11 rows selected.

SQL>
==

You can always turn the above into a pipeline and see it works. As a matter of interest, why recursion in PL/SQL? Not something that is the norm.

--
Billy
Received on Fri Aug 19 2005 - 06:03:08 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US