Syntax:
DECLARE
; Declaration section
…executable statement;
EXCEPTION
WHEN ex_name1 THEN
; Error handling statements/user defined action to be carried out;
END;
Types of Exception:
1) Predefined Exception/system defined exception/named exception: Are always automatically raised whenever related error occurs. The most common errors that can occur during the execution of PL/SQL. Not declared explicitly i.e. cursor already open, invalid cursor, no data found, zero divide and too many rows etc. Programs are handled by system defined Exceptions.
2) User defined exception:
It must be declare by the user in the declaration part of the block where the exception is used. It is raised explicitly in sequence of statements using:
Raise_application_error(Exception_Number, Error_Message);
0 Comments