Mega Code Archive

 
Categories / Oracle PLSQL Tutorial / Function Procedure Packages
 

Use package member variable to pass value

SQL> SQL> create table t as select * from all_objects; Table created. SQL> SQL> create or replace package myPackage   2  as   3      type varchar2_array is table of varchar2(30) index by binary_integer;   4      type rc is ref cursor;   5      procedure index_by( p_owner in varchar2, p_object_name out varchar2_array,p_object_type out varchar2_array,p_timestamp out varchar2_array );   6      procedure ref_cursor( p_owner in varchar2, p_cursor in out rc );   7  end;   8  / Package created. SQL> SQL> create or replace package body myPackage   2  as   3  procedure index_by( p_owner in varchar2,p_object_name out varchar2_array,p_object_type out varchar2_array,p_timestamp out varchar2_array )   4  is   5  begin   6      select object_name, object_type, timestamp   7        bulk collect into p_object_name, p_object_type, p_timestamp   8        from t   9       where owner = p_owner;  10  end;  11  12  procedure ref_cursor( p_owner in varchar2,p_cursor in out rc )  13  is  14  begin  15      open p_cursor for select object_name, object_type, timestamp from t where owner = p_owner;  16      end;  17  end;  18  / Package body created. SQL> SQL> drop table t; Table dropped. SQL>