--自定义例外
declare
cursor p_scursor is select ename from emp where empno=50;
p_ename emp.ename%type;
--定义自定义的例外
no_empname_found exception;
begin
open p_scursor;
fetch p_scursor into p_ename;
if p_scursor%notfound then
raise no_empname_found;
end if;
close p_scursor;
exception
when no_empname_found then dbms_output.put_line('没有此员工号');
when others then dbms_output.put_line('其他异常。。。');
end;
declare
cursor p_scursor is select ename from emp where empno=50;
p_ename emp.ename%type;
--定义自定义的例外
no_empname_found exception;
begin
open p_scursor;
fetch p_scursor into p_ename;
if p_scursor%notfound then
raise no_empname_found;
end if;
close p_scursor;
exception
when no_empname_found then dbms_output.put_line('没有此员工号');
when others then dbms_output.put_line('其他异常。。。');
end;