分类: Oracle
2007-06-27 21:41:35
C:oracleora92sqlplusdemo>sqlplus /nolog
SQL*Plus: Release 9.2.0.1.0 - Production on 星期六 4月 2 11:09:06 2005
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
SQL> conn
已連線.
SQL> create or replace procedure getEmpByDept(in_deptNo in emp.deptno%type,
2 out_curEmp out SYS_REFCURSOR) as
3
4 begin
5 open out_curEmp for
6 SELECT * FROM emp WHERE deptno = in_deptNo ;
7 EXCEPTION
8 WHEN OTHERS THEN
9 RAISE_APPLICATION_ERROR(-20101,
10 'Error in getEmpByDept' || SQLCODE );
12 end getEmpByDept;
13 /
已建立程序.
SQL> var rset refcursor;
SQL> exec getEmpByDept(10,:rset);
PL/SQL 程序順利完成.
SQL> print rset;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- -------------------- ------------------ ---------- ---------- ---------- ---------- ----------
7934 MILLER CLERK 7782 23-1月 -82 1300 10
7782 CLARK MANAGER 7839 09-1月 -81 2450 10
7839 KING PRESIDENT 17-11月-81 5000 10
SQL>