Exception Handler

An Exception Handler is nothing but a code block in memory that will attempt to resolve the current exception condition. The Oracle engine can recognize every exception condition that occurs in memory. To handle very common and repetitive exception conditions the Oracle engines uses Named Exception Handlers.

The Oracle engine has about fifteen to twenty named exception handlers. In addition to this the Oracle engine uses more than twenty thousand numbered exception handlers. These exception handlers are identified not by names but by four integers preceded by a hypen that is -1414. These exception handler names are actually a set of negative signed integers.

Each exception handler, irrespective of how it is identified (i.e. by Name or Number) has code attached that will attempt to resolve an exception condition. This is how Oracle's Default Exception-Handling strategy works.

The exception handler scans the PL/SQL block for the existence of an Exception section within the PL/SQL block. If an exception section within the PL/SQL block exists the exception handler scans the first word,after the action word When,within this exception section.

If the first word after the action word When,is the exception handler's name then the exception handler executes the code contained in the Thensection of the construct as follows.

When {Exception Name} Then {User defined action to be carried out}

The first word that follows the action word When must be 'String'.Hence this technique will work well for the fifteen to twenty 'named exception handlers'. In addition to these the Oracle engine has twenty thousand,numbered exception handlers,which are raised automatically and appropriately when the Oracle engine recognizes and exception condition. User defined exception handling code must be permitted even for these (numbered) exception handlers.

No comments: