Oracle数据的显示游标
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;
- /