DECLARE
past_due exception;
CURSOR emp_cur IS
select distinct e.empno as enum,e.ename,e.hiredate,e.sal,e.job1,e.comm,e.deptno,e.mgr
from emp e join emp m
on m.mgr=e.empno;
c1 emp_cur%ROWTYPE;
BEGIN
OPEN emp_cur;
LOOP
FETCH emp_cur INTO c1;
if emp_cur%NOTFOUND then
raise past_due;
/* INSERT INTO newempl(emp_id,emp_nm,emp_sal)*/
insert into newemp(dno,dname,ddate,dbasic,djob,dcomm,dept)
values( c1.enum,c1.ename,c1.hiredate,c1.sal,c1.job1,c1.comm,c1.deptno);
dbms_output.put_line(c1.enum||' '||c1.ename);
END LOOP;
exception
when past_due then
raise_application_error(-2100,'fetching the records is completed');
END;
我的错误是
错误报告: ORA-06550:第20行,PLS-00103栏:当遇到以下情况之一时遇到符号“LOOP”:
如果 ORA-06550:第25行,第4栏: PLS-00103:遇到以下任何一种情况时遇到符号“文件结束”:
结束不是pragma最终可实例化的命令覆盖静态 成员构造函数映射 06550. 00000 - “行%s,列%s:\ n%s” *原因:通常是PL / SQL编译错误。 *行动: 我并不知道错误是什么
答案 0 :(得分:1)
尝试使用此功能,在提出异常后end if;
缺失。
DECLARE
past_due EXCEPTION;
CURSOR emp_cur
IS
SELECT DISTINCT e.empno AS enum,
e.ename,
e.hiredate,
e.sal,
e.job1,
e.comm,
e.deptno,
e.mgr
FROM emp e JOIN emp m ON m.mgr = e.empno;
c1 emp_cur%ROWTYPE;
BEGIN
OPEN emp_cur;
LOOP
FETCH emp_cur INTO c1;
IF emp_cur%NOTFOUND
THEN
RAISE past_due;
END IF;
/* INSERT INTO newempl(emp_id,emp_nm,emp_sal)*/
INSERT INTO newemp (dno,
dname,
ddate,
dbasic,
djob,
dcomm,
dept)
VALUES (c1.enum,
c1.ename,
c1.hiredate,
c1.sal,
c1.job1,
c1.comm,
c1.deptno);
DBMS_OUTPUT.put_line (c1.enum || ' ' || c1.ename);
END LOOP;
EXCEPTION
WHEN past_due
THEN
raise_application_error (-2100, 'fetching the records is completed');
END;