oracle package中游标报错
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