2011-01-19 9 views
1

if_typenumber_infectedの代わりに、すべての列「*」を選択するにはどうすればよいですか?PL SQLすべての列を選択する方法

--spec 
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; 
/

--body 
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; 
/

答えて

5

あなたの質問と要件を理解しているかどうかわかりません。

しかし、あなたは、テーブルの内容を取得する方法、またはその一部を探しているなら、これはあなたがそれに近づくだろうか、おそらくです:

create table tq84_test_table (
    col_1 number, 
    col_2 varchar2(10), 
    col_3 date 
); 

insert into tq84_test_table values (1, 'one' , sysdate); 
insert into tq84_test_table values (2, 'two' , sysdate+1); 
insert into tq84_test_table values (3, 'three', sysdate-1); 


create or replace package tq84_sss as 

    type record_t is table of tq84_test_table%rowtype; 

    function GetADedIcWarningsProv return record_t; 

end; 
/

create or replace package body tq84_sss as 

    function GetADedIcWarningsProv return record_t 
    is 
     ret record_t; 
    begin 

     select * bulk collect into ret 
     from tq84_test_table; 

     return ret; 

    end GetADedIcWarningsProv; 

end; 
/

あなたは、後でそのように、この機能を使用します。

declare 

    table_content tq84_sss.record_t; 

begin 

    table_content := tq84_sss.GetADedIcWarningsProv; 

    for i in 1 .. table_content.count loop 

     dbms_output.put_line(table_content(i).col_1 || ' ' || 
          table_content(i).col_2 || ' ' || 
          table_content(i).col_3 
         ); 

    end loop; 

end; 
/
+3

を使用テーブル定義から派生したレコードタイプを明記してください: 'record_t型はtq84_test_table%rowtypeのテーブルです。 ' –

0

だけでストレスへのキーポイントは、あなたが `` *を選択したい場合は、その後、あなたは解除すべきであるということです%の行型

declare 
... 
someTableRow someTable%rowtype; 
... 
begin 
select * into someTableRow from someTable where blah; 
...