SQL>
SQL> create or replace procedure p_validatezip (i_zipCode VARCHAR2)
2 is
3 e_tooShort EXCEPTION;
4 e_tooLong EXCEPTION;
5 e_badZip EXCEPTION;
6 pragma exception_init(e_badZip, -20998);
7 v_tempZip NUMBER;
8 begin
9 if length(i_zipCode)< 5 then
10 Raise e_tooShort;
11 elsif length(i_zipCode)> 6 then
12 Raise e_tooLong;
13 end if;
14 v_tempZip := to_number(i_zipCode);
15 exception
16 when e_tooLong then
17 raise e_badZip;
18 when e_tooShort then
19 raise e_badZip;
20 when VALUE_ERROR then
21 raise e_badZip;
22 when e_badZip then
23 DBMS_OUTPUT.put_line('problem with Zip');
24 raise;
25 end;
26 /
Procedure created.
SQL> begin
2 p_validatezip('9406123123');
3 end;
4 /
begin
*
ERROR at line 1:
ORA-20998:
ORA-06512: at "RNTSOFT.P_VALIDATEZIP", line 17
ORA-06510: PL/SQL: unhandled user-defined exception
ORA-06512: at line 2
SQL>