The document below contains patterns of bad SQL and PL/SQL code that Gojko Adzic has repeatedly found in various applications and databases. Some of the bad practices include:
- Use of WHEN OTHERS in exception handling.
- Embedding complex SQL inside PL/SQL code.
- Poor PL/SQL error handling.
- Hardcoding the size of PL/SQL variables.
- Not using bind variables.
- Storing ROWIDs for later reference.
- Storing an empty LOB instead of NULL.
- Use of COMMIT or ROLLBACK inside stored procedures or functions.
- Use of magic numbers and strings instead of NULL.
Finally, Gojko makes the case against “wrapping everything into stored procedures”. He argues that instead of encapsulating all read/write access to data inside stored procedures, a better approach is to use views and instead-of triggers. Now that may make Steven nod his head in disagreement.
Have you used views instead of stored procedures to encapsulate data access, including inserts and updates? What do you think about this approach?
Oracle SQL and PLSQL Bad Practice - Get more free documents
More Resources:
- Cleaning Up PL/SQL Practices
- PL/SQL Best Practices White Paper (PDF) By Steven Feuerstein
- Oracle PL/SQL Best Practices and Common Mistakes Videos
- Oracle PL/SQL Best Practices Examples
- Oracle PL/SQL Best Practices, Second Edition Website
Related articles:
- Oracle PL/SQL Best Practices and Common Mistakes Videos
- Oracle Best and Worst Practices Wiki
- Oracle PLSQL in CFQUERY
- Most Developers are Young and Clueless About Databases and SQL
- Oracle Database 11g New PL/SQL Features in your 10g Code Today
Tagged pl/sql, sql | Post a Comment | Trackback URI


















Add New Comment
Viewing 4 Comments
Thanks. Your comment is awaiting approval by a moderator.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Add New Comment
Trackbacks
(Trackback URL)
March 14, 2008 at 9:55 am
[...] Awad gives us the Oracle SQL and PL/SQL Bad Practices Document, which “. . . contains patterns of bad SQL and PL/SQL ...