• Syntax:

DECLARE

exceptionName EXCEPTION;
 PRAGMA EXCEPTION_INT (exceptionName, errorName);
BEGIN
--Execute Commands. . .
EXCEPTION
WHEN exceptionName THEN
---code to handle Exception. . .  .
END;
/

Description:

  • An exception is declared in declaration section.
  • A PRAGMA is a call to pre-compiler that binds the numbered exception to some name.
  • A function EXCEPTION_INIT takes two parameters: one is exception name, and other is number of the exception to be handled.
  • Once binding is provided, exception can be handled in exception handling section using WHEN clause.