Chapter 16

Ten Common Mistakes to Avoid in PL/SQL

In This Chapter

bullet Recognizing bad exception handling

bullet Controlling conditions, cursors, and loops

bullet Reusing code effectively

bullet Writing code that’s easy to read and maintain

No matter how hard programmers try to make their code error free, they’re still human, and every system includes code that contains mistakes. In addition to simple mistakes in coding, some global mistakes are common among inexperienced programmers. To help you recognize these problems and get up to speed with PL/SQL more easily, this chapter describes ten of the most important mistakes to avoid when writing PL/SQL.

Catching an Exception with WHEN OTHERS THEN NULL

Never catch an unidentified exception without logging information about it. Chapter 15 mentions that the exception handler WHEN OTHERS is extremely useful, but it can also be the source of the most dangerous line of code that can exist in PL/SQL, as shown here:

begin

    ...

exception

when others then

null;

end;

Unless you’re in the debugging or development mode, never use an exception handler like ...

Get Oracle PL/SQL For Dummies now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.