Unanswered: Halting PL/SQL execution in package begin block
I have a unique PL/SQL question. When an exception is raised in the BEGIN block of a package body, how can I terminate execution of the package body (and not execute whatever was called in the package)?
Here are some code examples to show you my dilemma.....
PACKAGE BODY myPackage IS
PROCEDURE myPackageProcedure IS
--Call another package that may or may not call "mySessionTimeout()"
WHEN OTHERS THEN
IF (SQLCODE = -20123) THEN
PROCEDURE mySessionTimeout IS
raise_application_error (-20123,'Expired Session');
PROCEDURE callingProcedure IS
Whenever I call "myPackage.myPackageProcedure", the initialization block in "myPackage" gets executed prior to the execution of "myPackageProcedure" (which is what I want). If the package initialization block happens to call "mySessionTimeout", the URL is redirected (as desired), the exception -20123 is raised, the exception handler in the package body catches the exception, but then the original procedure that was called (myPackageProcedure) executes after the URL is redirected.
If I don't handle the exception, this prevents "myPackageProcedure" from executing, but then there's a messy exception dump in the web browser and the new web page isn't displayed.
If I don't raise an exception in "mySessionTimeout", then it's redirected to the new URL, but still executes the original called procedure (myPackageProcedure).
Is there a way to explicitly halt execution of the call stack and prevent a procedure from returning to it's caller? If so, I could do this in "mySessionTimeout" so that it wouldn't even return to the package "myPackage".