如果无数据抛出异常,如果有数据打印数据,我给10号部门,为什么还是会抛出自定义的例外呢
set SERVEROUTPUT ON;
declare
no_data exception;
cursor cur_emp(dno number) is select ename from emp where DEPTNO=dno;
pname emp.ename%type;
begin
open cur_emp(10);
loop
fetch cur_emp into pname;
if cur_emp%found then
dbms_output.put_line(pname);
elsif cur_emp%notfound then
raise no_data;
end if;
end loop;
close cur_emp;
exception
when no_data then dbms_output.put_line('没有部门为50号的员工信息');
when others then dbms_output.put_line('其他例外');
end;
/