Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

can a pipelined function return multiple times?

greddyJul 29 2011 — edited Jul 29 2011
   Hi,

     I have a situation where i have multiple cursor loops within a cursor loop in a pipeline function.

     my pipelined function looks like this in Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production on Linux
 create function pipelined_example return record_type pipelined
 is
 
    type rec1 is record
    (a     varchar2(20),
     b    varchar2(30),
     c     date,
     d     number,
     e     varchar2(20)
    );

   TYPE t_associate_array IS TABLE OF rec1
   INDEX BY PLS_INTEGER;

   array_tab         t_associate_array;

 
 begin
         cursor1 loop
            
             array_tab(1).a := cursor1_rec.a;
             array_tab(1).b := null;
             array_tab(1).c := cursor1_rec.a;
             array_tab(1).d := null;
             array_tab(1).e := cursor1_rec.e;

             pipe row(issue_records(array_tab(1).a,
                                              array_tab(1).b,
                                              array_tab(1).c,
                                              array_tab(1).d,
                                              array_tab(1).e
                                             )
                          );
             RETURN;
            
             cursor2 loop
                  array_tab(1).a := null;
                  array_tab(1).b := cursor1_rec.a;
                  array_tab(1).c := cursor1_rec.a
                  array_tab(1).d := cursor1_rec.d;
                  array_tab(1).e := cursor1_rec.e;

                   pipe row(issue_records(array_tab(1).a,
                                              array_tab(1).b,
                                              array_tab(1).c,
                                              array_tab(1).d,
                                              array_tab(1).e
                                             )
                          );
                   RETURN;

             end loop;  --of cursor2

             cursor3 loop
                  array_tab(1).a := null;
                  array_tab(1).b := cursor1_rec.a;
                  array_tab(1).c := null;
                  array_tab(1).d := cursor1_rec.d;
                  array_tab(1).e := null;

                   pipe row(issue_records(array_tab(1).a,
                                              array_tab(1).b,
                                              array_tab(1).c,
                                              array_tab(1).d,
                                              array_tab(1).e
                                             )
                          );

                   RETURN;

             end loop;  --of cursor3

         end loop;  --of cursor1
     
 end pipelined_example;
  The function is compiled successfully but, it is not returning any thing.

   Is piping out the records multiple times in pipelined function allowed?

   Am i missing some thing here?

   Please advice.

   Thanks!
   RG.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 26 2011
Added on Jul 29 2011
9 comments
468 views