/*
自定义例外:当没有查询到员工信息时,抛出例外
*/
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;
/
自定义例外:当没有查询到员工信息时,抛出例外
*/
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;
/