Oracle/PL/SQL

15일차 # 8-11: [1] when 이름 then

Bohemian life 2012. 4. 24. 21:53

        create or replace procedure up_exceptions1(a number, b number)

is 

 v_ret number;

begin

 v_ret := a/b;

 p(v_ret);

end;

/


exec up_exceptions1(100, 10)   --> 정상 처리

exec up_exceptions1(100, 0)    --> 에러: ORA-01476: 제수가 0 입니다


↓ ↓ ↓ 


create or replace procedure up_exceptions1(a number, b number)

is 

 v_ret number;

begin

 v_ret := a/b;

 p(v_ret);

exception

 when ZERO_DIVIDE then

   p('주인님, 0으로 나누시면 안되옵나이다.');

end;

/


exec up_exceptions1(100, 10) 

exec up_exceptions1(100, 0)