plsql存过声明游标_Oracle -PLSQL存储过程游标当出参

包头:

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      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);

11    end loop;

12  end;

13  /

------------------------

10 ACCOUNTING NEW YORK

20 RESEARCH DALLAS

30 SALES CHICAGO

40 OPERATIONS BOSTON

PL/SQL procedure successfully completed

记录一下实践结果,哈哈哈

原文:http://blog.csdn.net/lifang123456/article/details/39188077

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值