Baotou:
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;
Inclusion
Create or Replace package body Produrececursordata is
PROCEDURE Procedure1 (cur out curtype)
As
Begin
Open cur for select * from DEPT;
End
End Produrececursordata;
Test:
Sql> select * from DEPT;
DEPTNO dname LOC
------ -------------- -------------
Ten ACCOUNTING NEW YORK
DALLAS
SALES CHICAGO
OPERATIONS BOSTON
Sql> set Serveroutput on
Sql> Declare
2 Curoutarg Produrececursordata.curtype;
3 Rec_arg Produrececursordata.type_record;
4 begin
5 dbms_output.put_line ('------------------------');
6 Produrececursordata.procedure1 (CUROUTARG);
7 loop
8 Fetch curoutarg into Rec_arg;
9 Exit when Curoutarg%notfound;
10 Dbms_output.put_line (rec_arg.deptno| | ' ' | | rec_arg.dname| | ' ' | | REC_ARG.LOC);
one end loop;
The end;
13/
------------------------
Ten ACCOUNTING NEW YORK
DALLAS
SALES CHICAGO
OPERATIONS BOSTON
PL/SQL procedure successfully completed
Record the results of the practice, hahaha.
Oracle-plsql stored procedure cursor when the parameter is