1、游标的分类
隐式游标:所有的select语句和DML语句,内在都含有游标。
显式游标:有开发人员声明和控制。用于从结果集中取出多行数据,并将多行数据一行一行单独进行处理。***
2、定义游标
declare
cursor 游标名称
is
查询语句;
begin
--其他语句
end;
列子:
declare
cursor cur_stu
is
select name from student where id=2;
sname student.name%type;
result varchar2(20);
begin
open cur_stu;
loop
fetch cur_stu into sname;
exit when cur_stu%notfound;
result:=result||sname||'';
end loop;
dbms_output.put_line('我的名字叫' || result);
close cur_stu;
end;

posted on 2015-05-26 16:52  吴仕华  阅读(161)  评论(0编辑  收藏  举报