create or replace package pk as
type tp is record (
id number,
name varchar2(20)
);
procedure p;
function f(o_obj in tp) return number;
end pk;
create or replace package body pk as
procedure p as
cursor o_csr is select id, name from t;
o_csr_obj o_csr%rowtype;
o_obj tp;
o_tmp number;
begin
open o_csr;
loop
fetch o_csr into o_csr_obj;
exit when o_csr%NOTFOUND;
o_obj.id := o_csr_obj.id;
o_obj.name := o_csr_obj.name;
--select f(o_obj) into o_tmp from dual;
end loop;
end p;
function f(o_obj in tp) return number as
begin
dbms_output.put_line('id is ' || o_obj.id);
dbms_output.put_line('name is ' || o_obj.name);
return 1;
end f;
end pk;
注释掉select f(o_obj) into o_tmp from dual;这一行,package就没有问题,这一行问题出在哪里呢
------解决方案--------------------
select f(o_obj) into o_tmp from dual;
改成
o_tmp:=f(o_obj);