Return to Snippet

Revision: 37275
at December 7, 2010 19:32 by robvl66


Initial Code
create table all_tables_plus as select * from all_tables where 1 = 2;
alter table all_tables_plus add (prev_table_name varchar2(30));



create or replace package ref_pkg is
  type refcur_tables IS REF CURSOR RETURN all_tables%ROWTYPE;
  type t_tables_plus IS TABLE OF all_tables_plus%ROWTYPE;
end ref_pkg;
/

create or replace function add_prev_table (cur_tables IN ref_pkg.refcur_tables)
return ref_pkg.t_tables_plus pipelined
IS
  l_prev_table_name VARCHAR2(30) := NULL;
  l_tables          all_tables%ROWTYPE;
  l_tables_plus     all_tables_plus%ROWTYPE;
BEGIN
  LOOP
   FETCH cur_tables INTO l_tables;
   EXIT WHEN cur_tables%NOTFOUND;
   l_tables_plus.table_name :=  l_tables.table_name;
   l_tables_plus.prev_table_name := l_prev_table_name;
   l_prev_table_name := l_tables.table_name;
   PIPE ROW(l_tables_plus);
  END LOOP;
END;
/


select table_name,prev_table_name
from table(add_prev_table(cursor(select * from all_tables)));

Initial URL


Initial Description


Initial Title
pipelined function consuming ref cursor

Initial Tags


Initial Language
PL/SQL