Tuesday, 15 July 2014

access ref cursor as out parameter in procedure in oracle

create or replace package localdbpackage_pkg as
procedure pz_populate_emp_table;
end localdbpackage_pkg;

create or replace package body localdbpackage_pkg as
procedure pz_populate_emp_table as
c_localrefcursor sys_refcursor;
v_empno number := 7369;
emp_rec emp%rowtype;
  begin  --7369
  remotedbpackage_pkg.pz_return_refcursor(v_empno,c_localrefcursor);
  for i in c_localrefcursor
    loop
      dbms_output.put_line(i.empno);
    end loop;
--  loop
/*  fetch c_localrefcursor into emp_rec;
  exit when c_localrefcursor%notfound;
  insert into emp_temp values emp_rec;
  end loop;  */
 -- commit;
 -- close c_localrefcursor;
   end pz_populate_emp_table;
   begin
     null;
end localdbpackage_pkg;

----------------------------------------------------------------
create or replace package remotedbpackage_pkg as
procedure pz_return_refcursor(p_empno in number, p_emp_refcursor out sys_refcursor);
end remotedbpackage_pkg;

create or replace package body remotedbpackage_pkg as
 procedure pz_return_refcursor(p_empno in number, p_emp_refcursor out sys_refcursor) as
  begin
    open p_emp_refcursor for select * from emp where empno = p_empno;
  end pz_return_refcursor;
  begin
    null;
end remotedbpackage_pkg;

No comments:

Post a Comment