ITPub博客

首页 > 应用开发 > IT综合 > 带参数的游标

带参数的游标

原创 IT综合 作者:nokilled 时间:2007-06-02 12:12:38 0 删除 编辑

declare
cursor c1(p_id int) is select * from t where id=p_id ;
begin
open c1( 1) ;
end;
---------------------------
create table hxz_01 (a int);
insert into hxz_01 values(1);
insert into hxz_01 values(2);
insert into hxz_01 values(2);
insert into hxz_01 values(3);
commit;
/
set serveroutput on
declare
cursor l_cursor(p int) is select * from hxz_01 where a = p;
l_tmp hxz_01%rowtype;
begin
open l_cursor(2);
loop
fetch l_cursor into l_tmp;
exit when l_cursor%notfound;
dbms_output.put_line(l_tmp.a);
end loop;
end;
/

--Ref cursor exampl
declare
type refcursor is ref cursor;
l_tmp hxz_01%rowtype;
l_cursor refcursor;
begin
open l_cursor for 'select * from hxz_01 where a = :p' using 2;
loop
fetch l_cursor into l_tmp;
exit when l_cursor%notfound;
dbms_output.put_line(l_tmp.a);
end loop;
end;
/

[@more@]

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/46907/viewspace-917145/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: buck into 练习
请登录后发表评论 登录
全部评论

注册时间:2007-12-30

  • 博文量
    108
  • 访问量
    299526