CREATE OR REPLACE
package pkg_test as
  type myrctype is ref cursor; 
   function get(intID number) return myrctype;
end pkg_test;
/
 
CREATE OR REPLACE
package body pkg_test as
   function get(intID number) return myrctype is
     rc myrctype;  
     sqlstr varchar2(500);
   begin
     if intID=0 then
      
        open rc for select id,name,sex,address,postcode,birthday from student;
     else
        
        sqlstr := 'select id,name,sex,address,postcode,birthday from student where id=:w_id';
        
        open rc for sqlstr using intid;
     end if;
 
     return rc;
   end get;
 
end pkg_test;
/