日期:2014-05-17  浏览次数:21052 次

pl/sql 警告: 创建的过程带有编译错误。

  1 create or replace procedure add_employee
  2 (eno number,name varchar2,sal number,
  3 job varchar2 default 'CLERK',dno number)
  4 is
  5 --declare
  6 e exception
  7 pragma exception_init(e,-2291);
  8 begin
  9 insert into emp (empno,ename,sal,job,deptno)
 10 values(eno,name,sal,job,dno);
 11 exception
 12 when dup_val_on_index then
 13 raise_application_error(-20000,'雇员号不能重复');
 14 when e then
 15 raise_application_error(-20001,'部门号不存在');
 16* end;
SQL> /

警告: 创建的过程带有编译错误。



我测试了,就是那个定义的 e 例外有问题,我是照书上抄的 不知道为什么会出现错误,请大家知道下,谢谢! 还有大家一般用什么pl/sql开发工具啊,感觉自带的sql*plus 用的不是很顺手。

------解决方案--------------------
SQL code

--你可以用show errors看下哪里错了
create or replace procedure add_employee
  (eno number,name varchar2,sal number,
  job varchar2 default 'CLERK',dno number)
  is
  --declare
  e exception;
  pragma exception_init(e,-2291);
  begin
   insert into emp (empno,ename,sal,job,deptno)
  values(eno,name,sal,job,dno);
  exception
  when dup_val_on_index then
  raise_application_error(-20000,'雇员号不能重复');
  when e then
  raise_application_error(-20001,'部门号不存在');
  end;
/