oracle游标返回日期,Oracle 游标返回结果集

Oracle 游标返回结果集

有俩种方法:

一种是声明系统游标,一种是声明自定义游标,然后后面操作一样,参数类型为

in out 或out

(1)声明个人系统游标.(推荐)

create or replace p_temp_procedure

(

cur_arg out sys_refcursor;     --方法1

)

begin

open cur_arg for select * from tablename;

end

调用

declare

cur_calling sys_refcursor;

begin

p_temp_procedure(cur_calling);  --这样这个游标就有值了

for rec_next in cur_calling loop

....

end loop;

end;

create or replace procedure getList(id in varchar2,mycur out sys_refcursor)

is

v_sql varchar2(4000);

begin

dbms_output.put_line('call it success');

v_sql:='select * from userbean s where s.id=:1';

open mycur for v_sql using id;

commit;

end;

create or replace procedure my_procedure

(mypageNo number,mypageSize number,myInfo_Cursor out sys_refcursor)

as

pageNO number;

pageSize number;

begin

open myInfo_Cursor for

select * from product

where pid between 1 + (pageNo - 1) * pageSize and 4 + (pageNo - 1) * pageSize;

end;

declare

my_cursor sys_refcursor;

begin

my_procedure(1,2,my_cursor);

for rec_next in my_cursor loop

dbms_output.put_line('pid:'||rec_next.pid||'  ptypeid:'||rec_next.ptypeid||'  proname:'||rec_next.proname||'  price:'||rec_next.price||'  pronum:'||rec_next.pronum);

end loop;

end;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值