oracle游标——(一)

oracle游标——(一)

简单的游标使用

DECLARE 

cursor c is SELECT * from "person" ORDER BY NAME DESC;
v_person c%rowtype;
begin
open c;
loop
FETCH c into v_person;
exit when (c%notfound);
dbms_output.put_line(v_person.GUID || '' || v_person.NAME);
end loop;
close c;
end;


DECLARE 
cursor c is SELECT * from "person" ORDER BY NAME ASC;
v_person c%rowtype;
begin
FOR v_person in c loop
dbms_output.put_line(v_person.GUID || '' || v_person.NAME);
end loop;

end;

//带有参数的游标

DECLARE 
cursor c(v_GUID "person".GUID%type,v_name "person".NAME%TYPE)
is SELECT * from "person" where GUID = v_GUID and NAME = v_name ORDER BY NAME ASC;
v_person c%rowtype;
begin
FOR v_person in c('61B9B8F980C142309B7D76C3DEB7D1D6','a') loop
dbms_output.put_line(v_person.GUID || ' ' || v_person.NAME);
end loop;
end;

阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wild46cat/article/details/51542605
个人分类: oracle
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

不良信息举报

oracle游标——(一)

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭