[ACCEPTED]-What is bad in "When Others Then Null" in PL/SQL?-plsql
The problem is, that you are catching all 2 exceptions, and then ignoring them. You'll 1 never know when something went wrong.
There's nothing wrong with this snippet 11 of code if you don't want the pl/sql block's 10 exception to propagate any further for example. If 9 you do it on purpose, it's not bad code 8 or a mistake. That's the catch all in pl/sql. And 7 there might be situations in code where 6 you have nested BEGIN/EXCEPTION/END blocks 5 and one might not want the transaction to 4 fail just if a particular cross section 3 of code fails. You can't state it's bad 2 coding if you do it intentionally for whatever 1 reason/requirement.
BEGIN
--something important here
--something even more important here
BEGIN
--something secondary goes here but not important enough to stop the process or
--log a message about it either
--maybe send an informative email to the support group or
--insert a log message when debugging the process or
--the list could go on and on here
EXCEPTION
--I don't care if this block fails, absorbing all errors regardless of type
WHEN OTHERS THEN NULL;
END;
-- something super important here, must happen
EXCEPTION
WHEN NO_DATA_FOUND THEN
-- do something useful for this exception
WHEN OTHERS THEN
-- do something by default if we don't expect this error
END;
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.