PL/SQL does not have a FINALLY clause, as you will find in many other languages. The code in this clause executes, no matter how the subprogram terminates (successfully or through an exception section. Because PL/SQL lacks FINALLY, if you have cleanup work to do when your program terminates, you have to make sure to include that code at the end of the executable section and also in every WHEN clause.
|
It would be very useful to have a section like the "finally" construction in Java. So you'd have a block of the form
BEGIN
...
EXCEPTION
...
FINALLY
...
END
where the code in the final section is always executed, regardless of how the block is exited. Often the EXCEPTION section would not be needed, as currently it is necessary to handle an exception just to do some clean up and then re-raise it. (Idea first brought to my attention by Chris Rimmer)
|