Best Practice
PL/SQL
A Best Practices Seminar
for PL/SQL Developers and DBAs
by Steven Feuerstein
steven@stevenfeuerstein.com
steven.feuerstein@quest.com
www.oracleplsqlprogramming.com
www.quest.com
www.unit-test.com
Copyright @ Steven Feuerstein 1998-2006. All rights reserved.
Author: Steven Feuerstein
Contributors:
John Beresniewicz
Dick Bolz
Daniel Clamage
Vadim Loevski
Bill Pribyl, Datacraft
This documentation is provided to students attending classes presented by
PL/Solutions instructors. Duplication and dissemination of this material, in whole
or part, is strictly prohibited unless agreement has been reached with
PL/Solutions.
The information in this document is subject to change without notice. If you find
any problems in the documentation, please report them at:
http://www.oracleplsqlprogramming.com
ORACLE, PL/SQL and SQL*Plus are registered trademarks of Oracle Corporation.
Oracle Developer/2000, Oracle Designer/2000, Oracle Reports, Oracle Graphics, and
Oracle Forms are trademarks of Oracle Corporation.
Best Practice PL/SQL
Table of Contents
BUILD YOUR DEVELOPMENT TOOLBOX..........................................6
UNIT TEST PL/SQL PROGRAMS .........................................................11
OPTIMIZE SQL IN PL/SQL PROGRAMS............................................37
BULK COLLECT AND FORALL............................................................38
HIDE SQL STATEMENTS TO AVOID REPETITION........................45
WRITE CODE ASSUMING CHANGE...................................................58
MANAGE ERRORS EFFECTIVELY AND CONSISTENTLY...........63
WRITE READABLE, MAINTAINABLE CODE...................................91
USE PACKAGES AS FOUNDATION CONSTRUCT...........................94
KEEP EXECUTABLE SECTIONS SMALL...........................................98