隐式游标

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;

相关文章:

  • 2022-12-23
  • 2021-12-04
  • 2021-08-06
  • 2021-05-24
  • 2022-12-23
  • 2022-01-19
  • 2021-08-24
猜你喜欢
  • 2021-10-19
  • 2022-12-23
  • 2021-06-27
  • 2021-09-01
  • 2022-01-04
  • 2021-06-19
  • 2022-12-23
相关资源
相似解决方案