2017-06-15 51 views

回答

2

您需要定義一個與最終查詢的投影相匹配的集合類型。在給出的代碼中,將來自table2的兩列隨後是table1的兩列。

事情是這樣的:

declare 
    type ab_rec is record (
     a2 table2.a%type 
     , b2 table2.b%type 
     , a1 table1.a%type 
     , b1 table1.b%type 
    ); 
    type ab_nt is table of ab_rec; 
    l_recs ab_nt; 
begin 
    WITH 
    with_b AS 
     (
     Select A, B from Table1 
    ) 
    SELECT * 
     bulk collect into l_recs 
    FROM 
      (Select A, B from Table2) a, with_b b 
      WHERE a.A = b.A(+) 
      order by a.A; 
..... 
end;