在网上找了很久的 存储过程返回OUT参数的游标 例子,都不理想,最后还是自己写个。以备后用。
包中带过程 要自己定义一个type [cur_name] is ref cursor游标,返回的时候就直接 procedure AAA(变量名 out [cur_name])如此申明OUT变量
--PL/SQL Code (包中带过程) 过程带游标的OUT参数,返回游标(ref cursor)
create or replace package my_pack as
type my_ref_cursor is ref cursor;
procedure getMyCursor(val out my_ref_cursor);
end my_pack;
create or replace package body my_pack as
procedure getMyCursor(val out my_ref_cursor)
is
begin
open val for select * from student;
end;
end my_pack;
存储过程 用系统默认的 sys_refcursor 游标类型 定义变量就OK了
--PL/SQL Code(存储过程) 带游标的OUT参数,返回游标(ref cursor)
create or replace procedure retCursor(ret_cursor out sys_refcursor)is
ret_cursor_value sys_refcursor;
begin
open ret_cursor_value for select * from student;
ret_cursor:=ret_cursor_value;
end retCursor;
包中带过程 要自己定义一个type [cur_name] is ref cursor游标,返回的时候就直接 procedure AAA(变量名 out [cur_name])如此申明OUT变量
--PL/SQL Code (包中带过程) 过程带游标的OUT参数,返回游标(ref cursor)
create or replace package my_pack as
type my_ref_cursor is ref cursor;
procedure getMyCursor(val out my_ref_cursor);
end my_pack;
create or replace package body my_pack as
procedure getMyCursor(val out my_ref_cursor)
is
begin
open val for select * from student;
end;
end my_pack;
存储过程 用系统默认的 sys_refcursor 游标类型 定义变量就OK了
--PL/SQL Code(存储过程) 带游标的OUT参数,返回游标(ref cursor)
create or replace procedure retCursor(ret_cursor out sys_refcursor)is
ret_cursor_value sys_refcursor;
begin
open ret_cursor_value for select * from student;
ret_cursor:=ret_cursor_value;
end retCursor;