带您了解Oracle显式游标

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

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

Oracle显式游标:

Oracle显式游标定义格式:   

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

Select 语句

例子

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

 

 

 

【编辑推荐】

Oracle存储过程的使用实例

Oracle命令行自定义编辑器vi

oracle命令行登录的实现

ORACLE增加表空间的实现

Oracle创建视图的语法

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

2010-10-22 13:34:49

SQL Server游

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-10-28 13:20:50

ORACLE reso

2010-11-15 10:40:58

Oracle启动参数

2010-10-26 11:55:21

Oracle OS备份

2010-10-27 16:22:07

Oracle层次查询

2010-10-27 14:27:13

oracle查询语句日

2010-10-27 14:57:24

Oracle查询

2010-10-25 15:20:23

Oracle数据转换函

2010-10-29 10:56:46

ORACLE用户验证

2010-10-26 11:28:33

ORACLE运行方式

2010-10-29 14:57:12

Oracle归档模式

2010-10-28 10:19:29

oracle权限管理

2010-10-27 15:58:01

Oracle临时表

2010-11-16 09:55:12

Oracle分区索引

2010-11-15 15:44:11

Oracle文件系统

2010-10-29 10:04:27

点赞
收藏

51CTO技术栈公众号