zoukankan      html  css  js  c++  java
  • Oracle 中游标实例

    隐式游标

    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;

  • 相关阅读:
    hdu 1716 排列
    codevs 2597 团伙
    创建了一个静态数组,越界访问为什么不报错
    hdu 2083 简易版之最短距离
    hdu 2073 无限的路
    hdu 2060 Snooker
    hdu 1877
    hdu 1042 N!
    hdu 1799 循环多少次?
    百练:2972 确定进制
  • 原文地址:https://www.cnblogs.com/tohen/p/1584960.html
Copyright © 2011-2022 走看看