将 Subquery Factoring 的输出存储在 Bulk Collect 中
Store the output from Subquery Factoring in Bulk Collect
我想将查询的输出存储在
WITH
with_b AS
(
Select A, B from Table1
)
SELECT *
FROM
(Select A, B from Table2) a, with_b b
WHERE a.A = b.A(+)
order by a.A;
批量 collection。
您需要定义一个与最终查询的投影相匹配的集合类型。在给定的代码中,将是 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;
我想将查询的输出存储在
WITH
with_b AS
(
Select A, B from Table1
)
SELECT *
FROM
(Select A, B from Table2) a, with_b b
WHERE a.A = b.A(+)
order by a.A;
批量 collection。
您需要定义一个与最终查询的投影相匹配的集合类型。在给定的代码中,将是 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;