哪位给一个 存储返回结果集的例子啊带临时表那种,我知道oracle没有真正意义上的临时表。哪位给个例子啊
解决方案 »
- java如何读取plsql的对象数组,抛出异常:无效的名称模式
- oracle 中下面哪里出现的错误 怎么老是执行不了
- 大容量数据库设计问题?
- 输入一个这样的字符串‘\2\1\5\23\’编写函数,返回字符串中的数字的乘积。
- 大数据量表的问题?各位大侠帮帮忙
- 我第一次用oracle8.16,连接数据库的问题,谢谢!
- 能不能解决这样的问题?国庆了,我好想好好玩玩!
- 关于oracle中间表以及clob的问题
- 2个数据库整合起来,成为一个大的数据库,有什么方法可以操作?
- 求助!可不可以把一个用户的表和视图复制到另一个用户?
- oralce报表问题,欢迎大家来指导,谢谢*****
- oracle以前的数据怎么导入到现在的oracle中
mycursor out sys_refcursor
)
as
begin
open mycursor for select *from emp;
end;
/declare
cur sys_refcursor;
rec emp%rowtype;
begin
testRef(cur);
loop
fetch cur into rec;
exit when cur%notfound;
dbms_output.put_line(rec.ename);
end loop;
end;
/
而临时表是另外的,临时表的例子create global temporary table tmp_test as
select * from emp where 1=2;
insert into tmp_test select * from emp;
select * from tmp_test;
select id ID,name NOTEXISTCOL from t1
union all select id,name from t2
union all select id,name from t3
union all select id,name from t4
--然后最后选出来,一样的
--临时表没试过,不过临时表在commit或会话结束时会自动清空的,看你的临时表设置的是事务性的,还是会话性的了
create or replace procedure testRef(
mycursor out sys_refcursor
)
as
begin
insert into tmp_test select * from emp;
open mycursor for select * from tmp_test;
end;
/declare
cur sys_refcursor;
rec emp%rowtype;
begin
testRef(cur);
loop
fetch cur into rec;
exit when cur%notfound;
dbms_output.put_line(rec.ename);
end loop;
end;
/
试了下,可以的,那你就用临时表吧,第一次用,呵呵
begin
v_sql VARCHAR2(1000);
v_count number;
v_Plow number;
v_Phei number;
create global TEMPORARY table tmp_test(t1 int default 0) on commit preserve rows; insert into tmp_test
select * from emp;
open mycursor for
select * from tmp_test;
end;declare cur sys_refcursor; rec emp%rowtype;
begin
testRef(cur); loop fetch cur into rec; exit when cur%notfound; dbms_output.put_line(rec.ename);
end loop;
end;
麻烦再看下我上面写的语法没有问题吧