Oracle 将子查询分解的输出存储在批量收集中
我想将查询的输出存储在Oracle 将子查询分解的输出存储在批量收集中,oracle,oracle11g,toad,Oracle,Oracle11g,Toad,我想将查询的输出存储在 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; 进入批量收集。您需要定义与最终查询投影匹配的收集类型。在给定的代码中,这将是表2中的两列,然后是表1中的两列 大概是这样的: declare type ab_rec is r
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;
进入批量收集。您需要定义与最终查询投影匹配的收集类型。在给定的代码中,这将是
表2
中的两列,然后是表1
中的两列
大概是这样的:
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;
您需要定义与最终查询的投影匹配的集合类型。在给定的代码中,这将是
表2
中的两列,然后是表1
中的两列
大概是这样的:
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;