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;
- /