zoukankan      html  css  js  c++  java
  • Oracle 游标

    1:方式一

    declare     
           cursor c_job is select real_name,user_name,id from ram_user;--游标也是变量
           c_row c_job%rowtype; --定义一个游标变量c_row ,该类型为游标c_job中的一行数据类型
           v_result int;
    begin
           for c_row in c_job loop          
                select count(*) into v_result from ram_user_role where user_id = c_row.id;
                if v_result < 1 then
              -- dbms_output.put_line('sssssssss');
                   dbms_output.put_line(c_row.real_name || ':' || c_row.user_name);
                end if;
           end loop;
    end;

    2:方式二

    declare        
    cursor c_job is select empno,ename,job,sal from emp where job='MANAGER';--类型定义
    c_row c_job%rowtype;--定义一个游标变量
    begin
    open c_job;
    loop
    fetch c_job into c_row; --提取一行数据到c_row
    exit when c_job%notfound;--判读是否提取到值,没取到值就退出;取到值c_job%notfound 是false,取不到值是true
    dbms_output.put_line(c_row.empno||'-'||c_row.ename||'-'||c_row.job||'-'||c_row.sal);
    end loop;
    close c_job;
    end;
  • 相关阅读:
    FTP 协议和 HTTP 协议的比较
    HttpURLConnection的post请求,什么时候发出,writeData存在什么地方
    装饰器
    函数参数以及名称空间作用域
    函数的调用
    函数的返回值
    定义函数的三种方式
    函数
    day05
    day04
  • 原文地址:https://www.cnblogs.com/leonkobe/p/4259076.html
Copyright © 2011-2022 走看看