自定义例外:当没有查询到员工信息时,抛出例外

来源:互联网 发布:淘宝新店铺怎么运营 编辑:程序博客网 时间:2024/05/12 02:06
/*
自定义例外:当没有查询到员工信息时,抛出例外
*/
set serveroutput on
declare
   cursor c1(dno number) is select empno from emp where deptno=dno;
   no_data exception;
   pempno emp.empno% TYPE;
begin
  open c1(100);
  loop
    FETCH c1 into pempno;
    if c1%notfound then
      RAISE no_data;
    end if;
  end loop;
  close c1;
 
--例外
EXCEPTION
  when no_data then dbms_output.put_line('没有找到记录');
end;
/
原创粉丝点击