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
|
Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.4.0
Connected as mni
SQL>
SQL> Create Or Replace Procedure Get_EmpByDept (
2 Deptno In emp.deptno%Type,
3 refCrs Out sys_refcursor
4 ) Is
5 Begin
6 Open refCrs For
7 Select e.*
8 From emp e
9 Where e.deptno = Get_EmpByDept.deptno;
10 End;
11 /
Procedure created
SQL> set serveroutput on
SQL> Declare
2 rc sys_refcursor;
3 Employee emp%rowtype;
4 Begin
5 Get_EmpByDept(10, rc);
6 Loop
7 Fetch rc Into Employee;
8 Exit When rc%NOTFOUND;
9 --
10 dbms_output.put_line(Employee.ename);
11 --
12 End Loop;
13 Close rc;
14 End;
15 /
CLARK
KING
MILLER
PL/SQL procedure successfully completed
SQL> |
Partager