包头:
create or replace package ProdureceCursorData is type curtype is ref cursor;
type type_record is record
(
deptno NUMBER(2) ,
dname VARCHAR2(14),
loc VARCHAR2(13)
);
PROCEDURE Procedure1(cur out curtype);
end ProdureceCursorData;
包体:
create or replace package body ProdureceCursorData is PROCEDURE Procedure1(cur out curtype)
as
begin
open cur for select * from DEPT;
end;
end ProdureceCursorData;
测试:
SQL> select * from DEPT;
DEPTNO DNAME LOC
------ -------------- -------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
SQL> set serveroutput on
SQL> declare
2 curoutarg ProdureceCursorData.curtype;
3 rec_arg Prod