We discussed in the previous article (Expection Handling) that the exceptions can be either System pre-defined exceptions or User defined excpetions. Lets have a look on commonly used pre-defined exceptions with there error numbers:
One type of exception can be defined once in a block but different type of exceptions can be raised in the same block. And nested blocks can be used to specify same exception to handle in different ways.
For Ex:
Syntax:
DECLARE
Declaration section;
BEGIN
Executable statements ;
EXCEPTION
WHEN ex_name1 THEN
Error handling statements;
WHEN ex_name2 THEN
Error handling statements ;
WHEN Others THEN
Error handling statements ;
END;
| Named Exception | Error Number |
| DUP_VAL_ON_INDEX | ORA-00001 |
| TIMEOUT_ON_RESOURCE | ORA-00051 |
| TRANSACTION_BACKED_OUT | ORA-00061 |
| INVALID_CURSOR | ORA-01001 |
| NOT_LOGGED_ON | ORA-01012 |
| LOGIN_DENIED | ORA-01017 |
| NO_DATA_FOUND | ORA-01403 |
| SYS_INVALID_ROWID | ORA-01410 |
| TOO_MANY_ROWS | ORA-01422 |
| ZERO_DIVIDE | ORA-01476 |
| USERENV_COMMMITSCN_ERROR | ORA-01725 |
| INVALID_NUMBER | ORA-01722 |
| STORAGE_ERROR | ORA-06500 |
| PROGRAM_ERROR | ORA-06501 |
| VALUE_ERROR | ORA-06502 |
| ROWTYPE_MISMATCH | ORA-06504 |
| CURSOR_ALREADY_OPEN | ORA-06511 |
| ACCESS_INTO_NULL | ORA-06530 |
| COLLECTION_IS_NULL | ORA-06531 |
| SUBSCRIPT_OUTSIDE_LIMIT | ORA-06532 |
| SUBSCRIPT_BEYOND_COUNT | ORA-06533 |
| NO_DATA_NEEDED | ORA-06548 |
| CASE_NOT_FOUND | ORA-06592 |
| SELF_IS_NULL | ORA-30625 |
One type of exception can be defined once in a block but different type of exceptions can be raised in the same block. And nested blocks can be used to specify same exception to handle in different ways.
For Ex:
Syntax:
DECLARE
Declaration section;
BEGIN
Executable statements ;
EXCEPTION
WHEN ex_name1 THEN
Error handling statements;
WHEN ex_name2 THEN
Error handling statements ;
WHEN Others THEN
Error handling statements ;
END;
Nice post very helpful
ReplyDeletedbakings