解决方案 »
- Oracle的连接问题
- oracle 中一个字符串放在 varchar2(100)和varchar2(4000)字段中用的空间都是一样的吗?如果一样还用定义长度干什么?
- 请指教,为什么 COUNT(1) 返回总是 0
- odbc oracle driver for linux 哪有??
- visio数据库反向工程建立报错(急)
- 高手请进!!谁能帮我解释明白,高分相送!!!
- 请问vb连oracle一般用什么组建?
- 锁问题
- 请问DB2,ORACLE,SYSBASE,INFORMIX,SQLSERVER的存储管理器,查询处理器和事务管理器的实现技术分别是什么
- oracle的数据类型
- 请高手指点~一个关于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。