日期:2014-05-17  浏览次数:20909 次

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;


Compilation errors for PROCEDURE IDC.PRO_REPORT_HOUR
Error: PLS-00306: 调用 '||' 时参数个数或类型错误

求大牛帮忙解决。。。。
------最佳解决方案--------------------

bulk collect into ids from' 
------其他解决方案--------------------
tab_name; 
改成
bulk collect into ids from' 
------其他解决方案--------------------
tab_name.table_name;