解决方案 »
- oracle的查询语句,在线等,急!!
- 求 日期格式问题
- 关于多表查询问题
- oracl查询出的数据为什么为空,谁能帮帮我?
- 请问怎样把oracle数据库导出成sql语句啊?
- 请问:10g,所有服务已经启动了,但当指明服务名orcl后,为什么不能登录sql plus?
- 在定义表时,用varchar和varchar2之间有什么区别?
- 用什么类型的字段,varchar2不够长
- 如何用一条SQL语句获得每隔5分钟一个时间记录的结果?
- 急急,我编写的一个过程的状态为何总是“invalid”啊,在sqlplus里call时总是执行不了,为何?
- 请高手指点~一个关于RMAN自动备份的问题
- oracle10的初始账号是什么,我本地的密码为orcl
2.
3. 用ref_cursor返回。
o_Cur out SYS_REFCURSOR)
as
begin
open o_Cur for
select a
from test t
where t.a=i_id;
end;
create or replace procedure pro_test(ht_time varchar2)
is
ht_id varchar(20);
username varchar(200);
ht_qty integer;
ht_show varchar(2000); cursor cursor_a is select 发贴人,贴子ID from 表A;begin
open cursor_a;
loop
fetch cursor_a into username,ht_id;
exit when cursor_a%notfound;
select count(id) into ht_qty from 表B where 主贴ID = ht_id and to_char(回帖时间,'YYYYMM') = ht_time;
ht_show := '发贴人:'||username||',回贴数:'||ht_qty;
dbms_output.put_line(ht_show);
end loop;
close cursor_a;
end;
create or replace procedure pro_test(ht_time in varchar2,ref out sys_refcursor)
is
ht_id varchar(20);
username varchar(200);
ht_qty integer;
ht_show varchar(2000); cursor cursor_a is select 发贴人,贴子ID from 表A;begin
open cursor_a;
loop
fetch cursor_a into username,ht_id;
exit when cursor_a%notfound;
select count(id) into ht_qty from 表B where 主贴ID = ht_id and to_char(回帖时间,'YYYYMM') = ht_time;
ht_show := '发贴人:'||username||',回贴数:'||ht_qty;
dbms_output.put_line(ht_show);
end loop;
close cursor_a;
end;
在这里加个sys_refcursor。执行完后print。