Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: passing ref cursor on a procedure
I used the following program to learn bind variables and ref cursor
long time ago. This might help. Put this code into a file called
getstaff.sql and then run it. Bottom lines show how to declare a cursor
and pass it to a procedure using SQL.
HTH Mohammed Shakir
rem filename getstaff.sql
rem uses employee table(emp ??) from scott/tiger schema on oracle
rem you can use bind variables, then cursor can not have the return
type??.
rem You can return the ref cursor, see the multir~2.sql
rem This program works
rem USAGE: sqlplus scott/tiger @getstaff.sql
rem Originally this was multir~1.sql
drop package emp_data;
CREATE PACKAGE emp_data AS
TYPE EmpRecTyp IS RECORD (
emp_id NUMBER(4), emp_name CHAR(10), job_title CHAR(9), dept_name CHAR(14), dept_loc CHAR(13));
dept_no IN NUMBER, emp_cv IN OUT EmpCurTyp);
PROCEDURE get_staff (
dept_no IN NUMBER, emp_cv IN OUT EmpCurTyp) IS BEGIN OPEN emp_cv FOR SELECT empno, ename, job, dname, loc FROM emp, dept WHERE emp.deptno = dept_no AND emp.deptno = dept.deptno ORDER BY empno;
-- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Mohammed Shakir INET: [EMAIL PROTECTED] Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services --------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).Received on Mon Jun 09 2003 - 18:51:49 CDT