【发布时间】:2015-07-01 04:39:17
【问题描述】:
我想将 sys_refcursor 作为参数传递给 PL/SQL 中的过程。 我已经使用以下代码创建了一个过程
create or replace procedure reffunmani(
cname varchar2,
mysys out sys_refcursor)
is
begin
open mysys for
select /*c.ins_id,c.cname, c.start_date,*/i.ins_id,i.ins_name
from course c,institution i where c.ins_id=i.ins_id
order by c.start_date;
end;
/
show errors;
我已经将相同的过程称为匿名块
declare
mysys sys_refcursor;
rec institution%rowtype;
begin
reffunmani('MCA',mysys);
loop
fetch mysys into rec;
exit when mysys%notfound;
dbms_output.put_line(rec.ins_id||' '||rec.ins_name);
end loop;
close mysys;
end;
/
当我执行我的匿名块时,我得到一个错误
ORA-06504: PL/SQL: Return types of Result Set variables or query do not match
ORA-06512: at line 7
请注意,institution 表有 5 列。
【问题讨论】:
-
mysys是一个局部变量,因此您不会在它前面加上冒号(无论您使用什么前端工具,它都可能解释为绑定变量)。只需reffunmani('MCA',mysys); -
是的,我试过但没有用得到同样的错误信息
-
去掉冒号时包含错误编号的完整错误堆栈是什么?你的
institution表真的只有两列吗? -
没有,我的机构表有 5 列,而课程表有 5 列..
-
ORA-06504:PL/SQL:结果集变量或查询的返回类型不匹配 ORA-06512:第 7 行
标签: oracle join sys-refcursor