设为首页 加入收藏

TOP

Oracle-PLSQL存储过程游标当出参
2015-07-24 11:01:33 来源: 作者: 【 】 浏览:1
Tags: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

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

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇【oracle11g,8】数据字典和字符集 下一篇【Oracle】OCR的备份和恢复之导出..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·Redis 分布式锁全解 (2025-12-25 17:19:51)
·SpringBoot 整合 Red (2025-12-25 17:19:48)
·MongoDB 索引 - 菜鸟 (2025-12-25 17:19:45)
·What Is Linux (2025-12-25 16:57:17)
·Linux小白必备:超全 (2025-12-25 16:57:14)