15일차 # 8-18: [4] define
define => raise => when 이름 then
create or replace procedure up_exceptions4(a number)
is
v_sal emp.sal%type;
e_too_small exception; -- define exception
begin
select sal into v_sal
from emp
where empno = a;
if v_sal < 1000 then
raise e_too_small; -- raise exception
end if;
p('잘 처리되었사옵니다, 주인님!');
end;
/
exec up_exceptions4(7788)
exec up_exceptions4(7369) --> 에러: ORA-06510: PL/SQL: 처리되지 않은 user-defined 예외 상황
↓ ↓ ↓
create or replace procedure up_exceptions4(a number)
is
v_sal emp.sal%type;
e_too_small exception; -- define exception
begin
select sal into v_sal
from emp
where empno = a;
if v_sal < 1000 then
raise e_too_small; -- raise exception
end if;
p('잘 처리되었사옵니다, 주인님!');
/*
... 여러 실행문 ...
... 여러 실행문 ...
*/
exception
when e_too_small then -- trap exception
p('기본 급여가 너무 적사옵니다, 주인님!');
end;
/
exec up_exceptions4(7788)
exec up_exceptions4(7369)