|
|
|
Re: How to remove when others then [message #596119 is a reply to message #596116] |
Wed, 18 September 2013 02:51 |
|
Michel Cadot
Messages: 68645 Registered: March 2007 Location: Nanterre, France, http://...
|
Senior Member Account Moderator |
|
|
... and note that logging should be made in a procedure itself, maybe with "autonomous_transaction" pragma (depending on what you want to log).
In addition, if you need to raise an exception in your code you want to trap elsewhere there is no need to trap ALL exceptions (WHEN OTHERS):
declare
x exception;
begin
...
if <some condition> then raise x; end if;
...
exception
when x then <do something>;
end;
/
[Updated on: Wed, 18 September 2013 02:52] Report message to a moderator
|
|
|
|
Re: How to remove when others then [message #596125 is a reply to message #596124] |
Wed, 18 September 2013 03:29 |
cookiemonster
Messages: 13920 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
Though if you want an error message go back to the caller it's probably as easy to write:
declare
l_dummy varchar2(50):='value';
l_dummy1 varchar2(50);
l_str varchar2(100):='error occured in ';
l_msg varchar2(100);
begin
begin
if l_dummy is null then
l_msg:=l_msg||'l_dummy';
end if;
if l_dummy1 is null then
l_msg:=l_msg||' l_dummy1';
end if;
if l_msg is not null THEN
<do whatever, including calling logging procedure>
raise_application_error(-20000,'error occured');
end if;
end;
|
|
|
|