Oracle Training Oracle Support Development Oracle Apps

 
 Home
 E-mail Us
 Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB  

Don Burleson Blog 


 

 

 


 

 

   

 


PL/SQL Best Practices

The primary purpose of PL/SQL coding standards has always been to make maintenance easier for developers. PL/SQL best practices make the job even easier.  In order to satisfy the requirement for making maintenance easier for the developers, PL/SQL coding standards must address several areas of the development process. PL/SQL best practices take the implementation of coding standards to a higher level.

See my  notes on PL/SQL best practices:


Jay Singh posted a great set of PL/SQL best practices and coding guidelines on Oracle-L:

The following are the eight guidelines for PL/SQL best practices, according to Jay:

1) While writing PL/SQL, use the correct datatype so that implicit conversion will be avoided

2) Use bind variable to avoid unnecessary parsing

3) Use BULK COLLECT, % ATTRIBUTES wherever required

4) MODULARITY

Write the code that fit into your screen size.
Through successive refinement, you can reduce a complex problem to a
set of simple problems that have easy-to-implement solutions.


5) EXCEPTION WHEN OTHERS is almost always a BUG unless it is immediately
followed by a RAISE.  Use WHEN OTHERS exception as the last resort and handle exceptions.  For example:

EXCEPTION
WHEN OTHERS THEN
if (sqlcode=-54) then
.... deal with it.
else
RAISE;
end if;

6) Tom's Mantra

If (possible in SQL)
do it;
else if(possible in PL/SQL)
do it;
else if(possible in JAVA)
do it;
else
..
..
end if;

7) % ATTRIBUTES

Use %TYPE and %ROWTYPE attributes. No code change is required when schema structure changes. 

8) BEFORE VS AFTER TRIGGER

NEVER USE BEFORE TRIGGER FOR VALIDATIONS. Use BEFORE triggers ONLY to modify :NEW value.

Oracle Documentation States:

"BEFORE row triggers are slightly more efficient than AFTER row triggers. With AFTER row triggers, affected data blocks must be read (logical read, not physical read) once for the trigger and then again for the triggering statement. Alternatively, with BEFORE row triggers, the data blocks must be read only once for both the triggering statement and the trigger."


 

 

 
��
 
 
 
 

 
 
 

 
Oracle performance tuning software 
 
oracle dba poster
Oracle Linux poster
 
 

 

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  and include the URL for the page.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright 1996 -  2014

All rights reserved by Burleson

Oracle is the registered trademark of Oracle Corporation.