我要执行 select * from a01.temp
select * from a02.temp
.
.
.
select * from a500.temp
有没有办法定义一个变量@a,然后直接从a01到a500,然后我FOR @a = a01 to a500,select * from @a.temp就可以在plsql看到我要的效果,这个要怎么写呢?
select * from a02.temp
.
.
.
select * from a500.temp
有没有办法定义一个变量@a,然后直接从a01到a500,然后我FOR @a = a01 to a500,select * from @a.temp就可以在plsql看到我要的效果,这个要怎么写呢?
解决方案 »
- ora 00911 invaild character 问题
- 怎么解决oracle触发器不能对本表操作问题?
- 存储过程 输出函数为clob字段 为什么输出时还出现“ora-06502 字符串缓冲太小”错误
- oracle的安装
- 问几个管理的问题,分不够另加!
- 如果数据库中根据表t_table建立了若干个试图,能查询根据t_table所建立的视图的视图名吗??
- 为什么我的ORACLE8I没有办法SETUP?
- 请教一个简单问题???????????在线等候!!!!!!!!
- 各位大虾,请问怎么在proc 调用存储过程
- 图形界面解决oracle新建和连接数据库
- 如何实现公用查询结果集
- 在windows2008server下imp数据,出现中断问题事件名称: APPCRASH
spool my.sql
declare
v_int ......
begin
for ... loop
dbms_output.put_line('select * from a'||v_int||'.temp;');
...
end loop;
end;
/
spool offstart my.sql
is
a varchar2(10);
begin
for i in 1..500 loop
a:='';
a:=a||i;
select * from a.temp;
end loop;
end test1;
is
a varchar2(10);
begin
for i in 1..500 loop
a:='';
a:=a||i;
select * from a.temp;
end loop;
end test1;不要误人,,过程里面能直接单独使用 select 语句吗?
--先建个表存放结果,然后把查到德数据插入
create table test as select * from a01.temp where 1<>1;
DECLARE
V_TNAME VARCHAR2(10);
BEGIN
FOR V_CNT IN 1 .. 500 LOOP
IF V_CNT < 10 THEN
V_TNAME := '00' || V_CNT || '.temp';
ELSIF V_CNT >= 10 AND V_CNT < 100 THEN
V_TNAME := '0' || V_CNT || '.temp';
ELSE
V_TNAME := V_CNT || '.temp';
END IF;
--DBMS_OUTPUT.PUT_LINE('insert into test select * from '||v_tname||';');
EXECUTE IMMEDIATE 'insert into test select * from '||v_tname||';'
END LOOP;
END;
is
a varchar2(10);
begin
for i in 1..500 loop
a:='';
a:=a||i;
select * from a.temp;
end loop;
end test1;不要误人,,过程里面能直接单独使用 select 语句吗?
楼主是要将a500.temp表中每一项输出吗?create or replace procedure test1 is
a varchar2(100);
aa varchar2(100);
cursor dd is select 'aa' aa from a;
begin
for i in 1 .. 500 loop
a := '';
a := a || lpad(i, 3, '0');
open dd;
loop
fetch dd
into aa;
exit when dd%notfound;
dbms_output.put_line('aa:' || aa);
end loop;
close dd;
end loop;
exception
when others then
rollback;
end test1;
is
a varchar2(10);
begin
for i in 1..500 loop
a:='';
a:=a||i;
select * from a.temp;
end loop;
end test1;不要误人,,过程里面能直接单独使用 select 语句吗?
真的是误人,艹!!!
create or replace procedure test
as
t_sql varchar2(4000);
begin
for i in 1..10 LOOP
t_sql := t_sql || 'select * from a'|| lpad(i,3,'0')||'.temp union all ';
end LOOP;
t_sql := substr(t_sql,1,length(t_sql)-10);
dbms_output.put_line(t_sql);
end test;
500个 太长了 可以考虑建表 将500个表的数据 循环插入到新表 然后直接访问新表就可以了