带您了解Oracle显式游标

数据库 Oracle
Oracle中的游标分为静态游标和REF游标,而静态游标又分为显式(explicit)游标和隐式(implicit)游标。

Oracle显式游标是一类很重要的游标,下面就将为您详细介绍Oracle显式游标的用法,希望可以让您对Oracle显式游标有更多的了解。

Oracle显式游标:

Oracle显式游标定义格式:   

CURSOR 游标名 ( 参数 )  [返回值类型]  IS

Select 语句

例子

  1. set serveroutput on  
  2.  
  3. declare  
  4.  
  5. cursor emp_cur ( p_deptid in number) is  
  6.  
  7. select * from employees where department_id = p_deptid;  
  8.  
  9. l_emp employees%rowtype;  
  10.  
  11. begin  
  12.  
  13.  dbms_output.put_line('Getting employees from department 30');  
  14.  
  15. open emp_cur(30);  
  16.  
  17.  loop  
  18.  
  19.  fetch emp_cur into l_emp;  
  20.  
  21.  exit when emp_cur%notfound;  
  22.  
  23.  dbms_output.put_line('Employee id '|| l_emp.employee_id || ' is ');  
  24.  
  25.  dbms_output.put_line(l_emp.first_name || ' ' || l_emp.last_name);  
  26.  
  27.  end loop;  
  28.  
  29.  close emp_cur;  
  30.  
  31.  dbms_output.put_line('Getting employees from department 90');  
  32.  
  33. open emp_cur(90);  
  34.  
  35.  loop  
  36.  
  37.  fetch emp_cur into l_emp;  
  38.  
  39.  exit when emp_cur%notfound;  
  40.  
  41.  dbms_output.put_line('Employee id '|| l_emp.employee_id || ' is ');  
  42.  
  43.  dbms_output.put_line(l_emp.first_name || ' ' || l_emp.last_name);  
  44.  
  45.  end loop;  
  46.  
  47.  close emp_cur;  
  48.  
  49. end;  
  50.  
  51. /  

 

 

 

【编辑推荐】

Oracle存储过程的使用实例

Oracle命令行自定义编辑器vi

oracle命令行登录的实现

ORACLE增加表空间的实现

Oracle创建视图的语法

责任编辑:段燃 来源: 互联网
相关推荐

2010-10-22 13:34:49

SQL Server游

2010-10-27 16:22:07

Oracle层次查询

2010-10-26 11:55:21

Oracle OS备份

2010-11-15 13:20:06

Oracle恢复结构

2010-10-25 15:04:39

Oracle文本函数

2010-10-25 09:39:43

Oracle FBI索

2010-10-29 15:37:51

Oracle物理结构

2010-11-15 10:40:58

Oracle启动参数

2010-10-28 13:20:50

ORACLE reso

2010-10-29 10:56:46

ORACLE用户验证

2010-10-25 15:20:23

Oracle数据转换函

2010-10-27 14:57:24

Oracle查询

2010-10-27 14:27:13

oracle查询语句日

2010-10-29 10:04:27

2010-10-25 17:13:08

oracle分组函数

2010-11-16 09:55:12

Oracle分区索引

2010-11-15 15:44:11

Oracle文件系统

2010-10-29 14:57:12

Oracle归档模式

2010-10-27 15:58:01

Oracle临时表

2010-10-28 10:19:29

oracle权限管理
点赞
收藏

51CTO技术栈公众号