当前位置:数据库 > Oracle >>

Oracle数据的显示游标

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
MySQL
Access
SQLServer
DB2
Excel
SQLite
SYBASE
Postgres
如果你遇到数据库难题:
请访问www.zzzyk.com 试试
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,