Oracle 中游标实例
2009-10-17 11:12
281 查看
隐式游标
begin
update try set 成绩=60 where 课程编号='C008' and 成绩<60;
if SQL%notfound then
dbms_output.put_line('There is no score below 60!');
end if;
end;
/
-- 游标变量的使用
declare
type cursor_type is ref cursor;
stu_cursor cursor_type;
v_stu 学生基本信息%rowtype;
notfound boolean;
begin
open stu_cursor for
select * from 学生基本信息 where 性别='女';
loop
fetch stu_cursor into v_stu;
notfound:=stu_cursor%notfound;
exit when notfound;
dbms_output.put_line(v_stu.学号||' '||v_stu.姓名||' '||v_stu.性别||' '||v_stu.民族);
end loop;
close stu_cursor;
open stu_cursor for
select * from 学生基本信息 where 性别='男';
loop
fetch stu_cursor into v_stu;
notfound:=stu_cursor%notfound;
exit when notfound;
dbms_output.put_line(v_stu.学号||' '||v_stu.姓名||' '||v_stu.性别||' '||v_stu.民族);
end loop;
close stu_cursor;
end;
begin
update try set 成绩=60 where 课程编号='C008' and 成绩<60;
if SQL%notfound then
dbms_output.put_line('There is no score below 60!');
end if;
end;
/
-- 游标变量的使用
declare
type cursor_type is ref cursor;
stu_cursor cursor_type;
v_stu 学生基本信息%rowtype;
notfound boolean;
begin
open stu_cursor for
select * from 学生基本信息 where 性别='女';
loop
fetch stu_cursor into v_stu;
notfound:=stu_cursor%notfound;
exit when notfound;
dbms_output.put_line(v_stu.学号||' '||v_stu.姓名||' '||v_stu.性别||' '||v_stu.民族);
end loop;
close stu_cursor;
open stu_cursor for
select * from 学生基本信息 where 性别='男';
loop
fetch stu_cursor into v_stu;
notfound:=stu_cursor%notfound;
exit when notfound;
dbms_output.put_line(v_stu.学号||' '||v_stu.姓名||' '||v_stu.性别||' '||v_stu.民族);
end loop;
close stu_cursor;
end;
相关文章推荐
- Oracle 中游标使用实例
- oracle中 游标实例
- Oracle游标变量的使用实例
- oracle动态游标实例
- Oracle 中游标使用实例
- Oracle 游标分类以及实例
- ORACLE动态游标及动态SQL使用实例
- Oracle游标练手实例
- Oracle带游标的存储过程在plus中的调用实例
- Oracle 游标应用实例
- Oracle 游标使用全解实例
- oracle调用子存储过程+游标循环实例
- ORACLE游标实例讲解 (2012-12-1510:16:54)转载▼
- (Oracle)游标的相关知识和实例
- 在oracle利用游标取数据库的结果集应用实例:
- Oracle 游标及存储过程实例
- oracle 游标实例
- Oracle游标的使用实例详解
- oracle游标循环和时间函数实例
- (Oracle)游标的相关知识和实例