PL/SQL Error Handling Interview Question and Answers
17. |
What happens after a sub-block handles an exception? |
|
When a sub-block handles an exception, the control passes to the next statement in the executable section of the enclosing block immediately after the END statement of the sub block. |
18. |
How is an exception raised and handled? |
|
When a runtime error occurs, an exception is raised. The exception is handled when this error is successfully handled by the PL/SQL code and is not allowed to propagate to the outward environment. Compilation error cannot be handled within the program; only runtime errors can be handled within the PL/SQL code. An exception can be raised:-
By a runtime Oracle error
-
By the RAISE statement
-
By calling the RAISE_APPLICATION_ERROR procedure
-
After an exception is raised, the control is passed to the exception section, where the code is written about how to handle the error that has occurred. The control cannot pass back to the executable section of the same block after the exception is handled.
|
19. |
Can RAISE_APPLICATION_ERROR be called in the executable section of the program unit? |
|
Yes, the RAISE_APPLICATION_ERROR procedure can be called in the executable section as well as the exception section of the PL/SQL code. |
20. |
Can processing be resumed from the point exception was raised after the exception is handled? |
|
- After the exception is handled, processing cannot be resumed within the executable section of the current block from where the exception was raised.
- The current block where the exception handler is declared will be terminated.
- The control will pass to the statement in the enclosing executable block.
- If there is no enclosing block, control will pass back to the calling host environment.
|