2011-01-18 3 views
0

参照多くのラッパーを置くために:How to make a wrapper to return something other than ref cursorPL SQLはどのように1つのパッケージに

を私は、彼らは当然の異なる列を返す、以下のような多くのラップ機能を持っています。どのように私はそれらをすべて1つのパッケージに入れることができます。以下の例は、毎回ラッパーパッケージを置き換えるためです。あなたが1つのレコードの定義と異なるごとに1つのテーブル定義を使用します

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; 
/
+1

私が正しく理解している場合、返される列ごとに型を定義する必要があり、サポート関数/ストアドプロシージャは適切な型を参照する必要があります。しかし、すべての列のデータ型が同じであれば、同じ型を使用できます。 –

+0

データ型がすべて同じではありません。 (wrappersmalples1 wrappersample2..3 ...)しかし、それは右のように見える – code511788465541441

答えて

4

は、私は私が別の戻り列と同じパッケージにそれぞれの多くを追加できるように上にグローバル宣言を削除する方法を知りたいです列セット。

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

'(/*...*/)とは何ですか?あなたの擬似コードですか? – code511788465541441

+0

@ user521180:コメント/コメントアウトされた詳細 –

関連する問題