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


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

对该题的分析如下:
由于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:游标类型

相关内容