oracle 获取表名,并对变量表名进行查询
本帖最后由 hao123yao 于 2012-11-16 11:49:03 编辑 任务描述:从数据中获取一定的表,再从每个表中获得一个字段集。。。
create or replace procedure pro_report_hour
is
cursor table_names --获得很多需要的表,表名以collect_datat_开头
is
select table_name from user_tables where table_name like 'collect_datat_%';
TYPE data_id_table is table of report_hour.data_collector_id %TYPE;
ids data_id_table; -- 用ids 存 获得的data_collector_id集
begin
for tab_name in table_names loop
execute immediate 'select data_collector_id
bulk collect into ids from' ||tab_name;
.....
end loop;
end pro_report_hour;