Oracle pipelined function with generic record type?

319 Views Asked by At

I have a pipelined function which returns results of a SQL query:

function my_pipelined_function(...)
    return rec_t
    PIPELINED is
  begin
    for l in (select * from ... join ... where ...) loop
       PIPE ROW(l);
    end loop;
  
    return;
  end;

This works, but I have to define the record and it's type in the package header:

 TYPE rec IS RECORD(
   some_date_param date,
   some_number_param number,
   ...
 );

 TYPE rec_t IS TABLE OF rec;

Ugly. Isn't there a way to avoid having to declare the "hard-coded" record with all types defined, one by one?

I saw the ANYDATA type, but I can't make it work. Should I use this approach, if yes, how to do it? If not, should I use some kind of ref cursor, or is this simply not possible at all in Oracle?

Thanks

0

There are 0 best solutions below