Oracle/PL/SQL
15일차 # 8-14: [2] 이름 부여 => when 이름 then
Bohemian life
2012. 4. 24. 21:54
* 이름 부여:
1) 선언부에서 exceptino type의 exception 변수를 선언
: 이 변수가 exception 이름이 됩니다.
2) 선언부에서 PRAGMA EXCEPTION_INIT(Exception 이름(변수), -에러 번호)
drop table t1 purge;
create table t1 (no number not null);
create or replace procedure up_exceptions2(a number)
is
begin
insert into t1 values (a);
end;
/
exec up_exceptions2(100) --> 정상 처리
exec up_exceptions2(null) --> 에러: ORA-01400: NULL을 ("TOP20"."T1"."NO") 안에 삽입할 수 없습니다
↓ ↓ ↓
create or replace procedure up_exceptions2(a number)
is
e_null exception;
pragma exception_init(e_null, -1400);
begin
insert into t1 values (a);
exception
when e_null then
p('널 값을 입력하시면 아니되옵니다, 주인님!');
end;
/
exec up_exceptions2(null)