使用raise抛出自定义例外
--自定义例外:查询50号部门的员工姓名
declare
cursor cemp is
select ename from emp where deptno = 50;
pename emp.ename%type;
--自定义例外
no_emp_found exception;
begin
open cemp;
fetch cemp
into pename;
if cemp%notfound then
raise no_emp_found;
end if;
close cemp;
exception
when no_emp_found then
dbms_output.put_line('没有找到员工');
when others then
dbms_output.put_line('其他例外');
end;