Home >Database >Mysql Tutorial >Oralce中返回结果集的存储过程ref cursor

Oralce中返回结果集的存储过程ref cursor

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-07 17:24:14986browse

由于Oracle的存储过程没有返回值,它的所有返回值都是通过out参数来代替的,列表同样也不例外,但是由于是集合,所以不能用一般的

有返回值的存储过程(列表 结果集)
 案例:编写一个过程,输入部门编号,返回该部门所有员工的信息。

对该题的分析如下:
由于Oracle的存储过程没有返回值,它的所有返回值都是通过out参数来代替的,列表同样也不例外,但是由于是集合,所以不能用一般的参数,必须要用package,所以分两部分:

 1)建一个包。如下:

create or replace package testpackage AS TYPE test_cursor is ref cursor;
end testpackage;

在该包中我定义了一个游标类型  test_cursor

下面就是写创建过程了
create or replace procedure chenchuang_pro
(chenNo in number p_cursor out testpackage.test_cursor) is
begin
open p_cursor for select * from emp wheredeptno=chenNo;
end;

ref cursor:游标类型

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn