create or replace package mypk
as
type t_cursor is ref cursor;
function func(a number) return t_cursor;
procedure proc(name varchar2,c out t_cursor,a number);
end;
/
create or replace package body mypk
as
function func(a number) return t_cursor
as
v_temp t_cursor;
begin
open v_temp for select * from test where id=a;
return v_temp;
end func;
procedure proc(name varchar2,c out t_cursor,a number)
as
begin
open c for select * from test where id=a and name=name;
end proc;
end;
/
注意:ref cursor一定要在包中以type声明,因为无法直接在func或proc中声明ref cursor类型.
在delphi中调用时,除了要设置扩展属性为PLSQLRSET=1外:
1.用adoquery时语句应该写为query.sql.text:='{call mypk.func()}';其中'()'可以省略;
2.用adostoredproc时procedurename='mypk.func';
3.使用存储过程返回结果集时在text中应该填入'{call mypk.proc(?,?)}',注意参数个数是除光标类型外的个数,顺序是除光标类型外的变量次序.
4.对于过程或函数调用的写法只能是'{call func/proc(?,?)}';
as
type t_cursor is ref cursor;
function func(a number) return t_cursor;
procedure proc(name varchar2,c out t_cursor,a number);
end;
/
create or replace package body mypk
as
function func(a number) return t_cursor
as
v_temp t_cursor;
begin
open v_temp for select * from test where id=a;
return v_temp;
end func;
procedure proc(name varchar2,c out t_cursor,a number)
as
begin
open c for select * from test where id=a and name=name;
end proc;
end;
/
注意:ref cursor一定要在包中以type声明,因为无法直接在func或proc中声明ref cursor类型.
在delphi中调用时,除了要设置扩展属性为PLSQLRSET=1外:
1.用adoquery时语句应该写为query.sql.text:='{call mypk.func()}';其中'()'可以省略;
2.用adostoredproc时procedurename='mypk.func';
3.使用存储过程返回结果集时在text中应该填入'{call mypk.proc(?,?)}',注意参数个数是除光标类型外的个数,顺序是除光标类型外的变量次序.
4.对于过程或函数调用的写法只能是'{call func/proc(?,?)}';