开发者

PL SQL How to put many wrappers in one package

reference: How to make a wrapper to return something other than ref cursor

I've got many wrapped functions that are similar to the one below, only they return different columns of course. How can i put them all in one package. because what the examples below does is replace my wrapper package everytime.

I want to know how to remove the global declarations on top开发者_如何学运维 so that i can add many in the same package each with different return columns

create or replace package WrapperSample is

  type TResultRow is record(
     if_type         codes.cd%type
    ,number_infected Integer);

  type TResultRowList is table of TResultRow;

  function GetADedIcWarningsProv
  (
    p_hos_id in work_entity_data.hos_id%type
   ,p_date   in date
  ) return TResultRowList
    pipelined;

end WrapperSample;
/

create or replace package body WrapperSample is

  function GetADedIcWarningsProv
  (
    p_hos_id in work_entity_data.hos_id%type
   ,p_date   in date
  ) return TResultRowList
    pipelined is
    v_refcur   eOdatatypes_package.eOrefcur;
    currentRow TResultRow;
  begin
    v_refcur := YourSchema.getADedIcWarningsProv(p_hos_id, p_date);

    loop
      fetch v_refcur
        INTO currentRow;
      exit when v_refcur%NotFound;
      pipe row(currentRow);
    end loop;

    close v_refcur;

    return;
  end;

end WrapperSample;
/


you would use one record definition and one table definition per different column set.

create or replace package WrapperSample is

  type R_WarningsProv is record(/*...*/);

  type T_WarningsProv is table of R_WarningsProv ;

  function GetADedIcWarningsProv(/*...*/) return T_WarningsProv pipelined;

  type R_OtherFunction is record(/*...*/);

  type T_OtherFunction is table of R_OtherFunction ;

  function OtherFunction(/*...*/) return T_OtherFunction pipelined;

  /* Multiple functions can use the same types as long as 
     they share the same column definition */

  function SomeOtherFunction(/*...*/) return T_OtherFunction pipelined;

end WrapperSample;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜