Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to re-raise pl/sql exception in exception handling block?

Tags:

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

like image 342
user2090855 Avatar asked Feb 20 '13 11:02

user2090855


1 Answers

If your error stays the same, change to

... exception when others then   log_error(sqlcode, sqlerrm);   raise; end; / 

This is explained in the documentation.

like image 124
igr Avatar answered Nov 03 '22 09:11

igr