0

Oracle 11g を使用しています。

だから、私はこのようなテストデータテーブルを持っているとしましょう

with test_data as (
    select 1 as id, 'John' as name from dual 
        union all
    select 2 as id, 'Jack' as name from dual
        union all
    select 3 as id, 'Peter' as name from dual
)

また、呼び出しごとに1 つの行piplinedを返す関数があり、次のような複数の列があります。

CREATE OR REPLACE PACKAGE MY_PACK AS
  TYPE result_record is RECORD(
   surname           varchar2(27),
   telephone          varchar2(50),
   place_of_birth     varchar2(50)
       );

  TYPE result_table IS TABLE OF result_record;
  function runPipe(id number) RETURN result_table PIPELINED;
END ERC_PACK;
/

CREATE OR REPLACE PACKAGE BODY MY_PACK AS
    function runPipe(id number) RETURN result_table PIPELINED IS
    rec           result_record:=null;
    begin
       if  (id=1) then
         select 'Smih','139289289','Paris' into rec from dual;
       end if;
       if  (id=2) then
         select 'Lock','1888888888','London' into rec from dual;
       end if;
       if  (id=3) then
         select 'May','99999999999','Berlin' into rec from dual;
       end if;
       pipe row (rec);
       return;
  end;
END ERC_PACK;
/

そしてもちろん、

select * from table(MY_PACK.runPipe(1)) 

戻り値

Smih    139289289   Paris

test_data ここで、パイプライン関数からの対応する値とともに、すべての行を返す select ステートメントが必要です

たとえば、次のようなもの

select test_data.*, (select * from table(MY_PACK.runPipe(id))) from test_data

もちろんこれは機能しません が、期待される結果は次のようになります。

1 John  Smih    139289289   Paris
2 Jack  Lock    1888888888  London
3 Peter May     99999999999 Berlin

test_dataでは、テーブルとpipelined関数が与えられた場合、上記の期待される結果をどのように達成するのでしょうか?

4

3 に答える 3