【发布时间】:2021-04-22 11:15:57
【问题描述】:
我想知道如何在 PL/SQL 块内的BULK COLLECT 中使用WITH 子句。
目前我可以将数据放入如下的集合变量中。
set serveroutput on;
declare
type row_data is table of varchar2(256) ;
row_d row_data;
begin
select some_column bulk collect into row_d from some_table;
dbms_output.put_line(row_d(1));
end;
但我需要从不同的表中获取数据。为此,我使用下面提到的 with 子句。
with diff_tab_data as
(
select some_column from some_table1;
union all
select some_column from some_table2;
union all
select some_column from some_table3;
union all
select some_column from some_table4;
union all
select some_column from some_table5;
);
select some_column from diff_tab_data;
如何将上述查询与批量收集一起使用。我已经尝试了以下相同的方法,但我收到了错误
set serveroutput on;
declare
type row_data is table of varchar2(256) ;
row_d row_data;
begin
with diff_tab_data as
(
select some_column from some_table1
union all
select some_column from some_table2
union all
select some_column from some_table3
union all
select some_column from some_table4
union all
select some_column from some_table5
);
select some_column into bulk collect row_d from diff_tab_data;
dbms_output.put_line(row_d(1));
end;
请求您在这方面提供帮助
【问题讨论】: