【发布时间】:2018-08-09 11:00:26
【问题描述】:
我正在尝试循环一些表并运行如下选择:
set serveroutput on
declare
type tables_names is table of varchar2(30);
type selectTable is table of varchar2(30);
tName tables_names;
sTableName selectTable;
begin;
tName := tables_names('PERIOD','SETTING','RAP','LOG');
sTableName := selectTable('m_table1','m_table2','m_table3','m_table4','m_table5');
for i in 1..tName.count loop
for j in 1..sTableName.count loop
select col10, count(*) from user.sTableName(j)
where table_name = tName(i) group by col10;
end loop;
end loop;
end;
我收到错误:PL/SQL: ORA-00933。
您能否告诉我如何正确运行 PL/SQL 程序以显示我选择的结果?
更新:查看结果
通常,为了得到这个,我需要在 select 下运行:
select column_name,
count(*) as countColumn
from user.m_table1 where table_name = 'PERIOD' group by column_name;
select column_name,
count(*) as countColumn
from user.m_table2 where table_name = 'PERIOD' group by column_name;
【问题讨论】:
标签: sql oracle loops plsql oracle12c