1. 程式人生 > >Oracle返回表集合函式

Oracle返回表集合函式

create or replace type type_col as object(e varchar2(36 char),n varchar2(100 char));
create or replace type type_tab  as table of type_col;

create or replace function f_return_rowtype(v_id varchar2)
  return type_tab
  pipelined as
  v type_col;
 
begin
  for myrow in (select e, n
                  from tab e
                 where 
                 start with e.id = v_id) loop
    v := type_col(myrow.e, myrow.n);
  
    pipe row(v);
  
  end loop;
  return;
exception
  when others then
    dbms_output.put_line('sqlcode : ' || SQLCODE);
    dbms_output.put_line('sqlerrm : ' || SQLERRM);
end;