关闭

oracle游标——(一)

86人阅读 评论(0) 收藏 举报
分类:

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;

1
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:261076次
    • 积分:6903
    • 等级:
    • 排名:第3347名
    • 原创:432篇
    • 转载:12篇
    • 译文:7篇
    • 评论:30条
    文章分类
    最新评论