oracle package中游标报错

wangsufu77 2016-02-03 09:40:35
create or replace package mypkg as
--定义一个返回值
TYPE Emp_Info_Type IS RECORD
(
EmpName VARCHAR2(10),
Job VARCHAR(9),
Sal NUMBER(7,2),
d_name dept.dname%type
);
--声明记录类型的变量
EmpInfo emp_Info_Type;

--定义一个游标
cursor e_cur(d_no in emp.deptno%type) return emp_Info_Type;
end mypkg;

create or replace package body mypkg as
--EmpInfo emp_Info_Type;
cursor e_cur(d_no in emp.deptno%type) return emp_Info_Type is
select e.ename,e.job,e.sal,d.dname from emp e,dept d where e.deptno=d.deptno and d.deptno=d_no;
open e_cur(11);
loop
fetch e_cur into EmpInfo;
exit when e_cur%notfound;
dbms_output.put_line(EmpInfo.EmpName);
end loop;
close e_cur;
end mypkg;

其中open e_cur(11);
close e_cur;报错如下:
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
7/1 PLS-00103: Encountered the symbol "FETCH" when expecting one of the following: constant exception <an identifier> <a double-quoted delimited-identifier> table long double ref char time timestamp interval date binary national character nchar
11/1 PLS-00103: Encountered the symbol "CLOSE" when expecting one of the following: end not pragma final instantiable order overriding static member constructor map
...全文
144 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
lhdz_bj 2016-02-09
  • 打赏
  • 举报
回复
包体定义格式似乎不对。 create or replace package body mypkg as procedure ... as cursor ...; begin open cursor...; loop ... end loop; end; function ... as begin ... end; end mypkg;

3,491

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 高级技术相关讨论专区
社区管理员
  • 高级技术社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧