How to re-raise pl/sql exception in exception handling block?
17,020
If your error stays the same, change to
...
exception when others then
log_error(sqlcode, sqlerrm);
raise;
end;
/
This is explained in the documentation.
Author by
user2090855
Updated on July 20, 2022Comments
-
user2090855 almost 2 years
I have the following procedure which is used by some applications:
procedure p1 is begin bla bla bla; end;
But there is no exception handling block. So applications were written according this feature.
Now I need to log errors in p1. But it shouldn't affect applications that use this procedure.
Something like this:
procedure p1 is begin bla bla bla; exception when others then log_error(sqlcode, sqlerrm); raise_new_exception (sqlcode, sqlerrm); end;
In case of raise_application_error first parameter should be in range [-20000, -20999]. So if there raises exception no_data_found, it cannot raise this error.
In case of exception_init, second parameter should not be variable. It must be numeric literal.
PS: As temporary solution, I'm using execute immediate
-
ceving over 9 years@AlexPoole Link dead.
-
Alex Poole over 9 years@ceving - thanks, I've put the current live link into the answer instead to it's easier to update in future.
-
loshad vtapkah about 9 yearsCurrent link
-
McK over 8 years@AlexPoole Link dead again. loshad vtapkah's link works currently.
-
Alex Poole over 8 years@McK - thanks; updated to current 11gR2 version which is what it used to point to (rather than the 9i one loshad linked to).
-
Nick over 6 yearsBad thing about raise is that it removes the error backtrace :(