When Others
Tuesday, August 22nd, 2006An interesting post by Tom Kyte on “When others” exception in PL/SQL.
“I see a when others then NULL. That is the worst thing a programmer could ever do. Basically you are saying “it does not matter if this code executes or not”. Well guess what - if it does not matter DO NOT EXECUTE IT ever!”
He is right and I have my personal experience to vouch it. Many programmers handle the “when others” which is a catch all for any type of exception by putting a null. Personally, I would like to use the when others to capture and inform what type of error it has captured like the code below
begin
…..
exception
When Others then
– either dbms out put or however you want to handle it.
dbms_output.put_line(”Unexpected error: “||substr(sqlerrm,1,250));
End;