GaussDB 100 游标---带参游标的应用示例
示例1,带参数的游标;
create or replace procedure test_getparameters (c1 in varchar2 , c2 in int )
is
cursor getsome(c5 varchar2 ,c6 int ) is
select * from test_02 where col1 = c5 and col2 =c6 order by id ;
corsor_record getsome%rowtype ;
begin
open getsome(c1 ,c2 );
loop
fetch getsome into corsor_record ;
exit when getsome%notfound ;
dbms_output.put_line('result is '||'-----'|| corsor_record.id ||corsor_record.col1||'-----'||corsor_record.col2);
end loop ;
close getsome ;
end;
/
说明;(1)带参数的游标在open时须传参,在fetch时不传参。
(2)游标名%notfoud 参数在游标获取不到参数时,返回false;
(3)loop循环,通过exit when条件跳出循环。
- 点赞
- 收藏
- 关注作者
评论(0)