An example of using PRAGMA EXCEPTION_INIT : Your Exception « PL SQL Programming « Oracle PL/SQL Tutorial






SQL>
SQL> create table org_level(
  2    company_id number(8)      not null,
  3    org_level varchar2(1) not null
  4  );

Table created.

SQL>
SQL> DECLARE
  2    invalid_org_level EXCEPTION;
  3    PRAGMA EXCEPTION_INIT(invalid_org_level,-2290);
  4  BEGIN
  5    INSERT INTO org_level VALUES (1001,'P');
  6    COMMIT;
  7  EXCEPTION WHEN invalid_org_level THEN
  8    dbms_output.put_line('Organization Level');
  9  END;
 10  /

PL/SQL procedure successfully completed.

SQL>
SQL> drop table org_level;

Table dropped.

SQL>








24.18.Your Exception
24.18.1.Create your own no_data_found EXCEPTION
24.18.2.An example showing handling of pre-defined exceptions
24.18.3.Catch 'cannot get lock exception'
24.18.4.Handling user-defined exceptions with a WHEN clause
24.18.5.An example of using PRAGMA EXCEPTION_INIT
24.18.6.Assign custom exception a number