2 Day Developer > Using PL/SQL > Handling PL/SQL Errors > Declaring PL/SQL Exceptions
Declaring PL/SQL Exceptions |
Previous |
Next |
Exceptions can be declared only in the declarative part of a PL/SQL block, subprogram, or package. You declare an exception by introducing its name, followed by the EXCEPTION
keyword. In Example: Determining the Scope of PL/SQL Exceptions, you declare an exception named past_due
that is raised when the due_date
is less than the today's date.
Exception and variable declarations are similar. But remember, an exception is an error condition, not a data item. Unlike variables, exceptions cannot appear in assignment statements or SQL statements. However, the same scope rules apply to variables and exceptions.