Function: Error Handling
Description: Types of Errors:
| DUP_VAL_ON_INDEX |
Unique constraint voilation |
| TIMEOUT_ON_RESOURCE |
Time out occurred |
| TRANSACTION_BACKED_OUT |
The transaction was rolled back |
| INVALID_CURSOR |
Illegal cursor operation |
| NO_DATA_FOUND |
No data found |
| TOO_MANY_ROWS |
A Select .. INTO statement had more than one match |
| CURSOR_ALREADY_OPEN |
Attempted to open a cursor that was already open. |
| ROWTYPE_MISMATCH |
PL/SQL cursor variable was assigned an incompatible row type. |
| OTHERS |
Other error messages not predefined |
Control passing to an exception handler
DECLARE A EXCEPTION BEGIN .... RAISE A ... EXCEPTION WHEN A THEN ....
|
SQLCODE and SQLERRM
SQLCODE - Oracle Error Number
SQLERRM - Descriptive Error Message
PRAGMA EXCEPTION_INIT
(exception_name, Oracle error number)
DECLARE
e_MissingNull EXCEPTION;
PRAGMA EXECEPTION_INIT(e_MissingNULL,-1400);
BEGIN
INSERT INTO temp (id) values (NULL);
EXCEPTION
WHEN e_MissingNull then
...
END;