used in SQL too it is good practice to write a deterministic package function for every constant Example (bad): DECLARE l_job employees job_id TYPE;
Previous PDF | Next PDF |
[PDF] Doing SQL from PL/SQL: Best and Worst Practices - Oracle
21 sept 2008 · A good understanding of all three methods is necessary for choosing the optimal method for a particular requirement Embedded SQL PL/SQL's
[PDF] TOP TWENTY PL/SQL TIPS AND TECHNIQUES
ORACLE PL/SQL: Programming with Packages (O'Reilly, 1996) He is Director of the Oracle Practice for SSC, a systems management consulting firm based in
[PDF] Exploring PL/SQL New Features and Best Practices for - DOAG
PL/SQL Function Result Cache – Subprogram Inlining – Finer Grained Dependencies • New Features in Oracle Database 12c • PL/SQL Best Practices and
[PDF] Oracle PL/SQL Best Practices - Index of
it fades, but in the case of the second edition of Oracle PL/SQL Best Practices, I managed to live out my fantasy all the way through You are holding the result in
[PDF] Oracle PLSQL Coding Guidelines 1 Overview 2 - Topcoder
All PL/SQL functions and procedures will be implemented as part of a package The package Oracle PL/SQL Best Practices, Steven Feuerstein, 2001
[PDF] PL/SQL & SQL Guidelines
used in SQL too it is good practice to write a deterministic package function for every constant Example (bad): DECLARE l_job employees job_id TYPE;
[PDF] OReillyOraclePLSQL Best Practicespdf - Directory UMM
16 nov 2000 · Oracle PL/SQL Best Practices is a concise, easy-to-use summary of best practices in the program development process It covers coding style,
[PDF] Best Practices for PL/SQL
Two days of the newest, best, most important features of Oracle PL/SQL □ The new PL/SQL Compiler – Optimizing compiler, compile-time warnings,
[PDF] Oracle Plsql Best Practices And Tuningpdf
9 sept 2001 · PL/SQL Tuning Best Practices ▫ What's wrong with this code? ▫ Setting expectations re: tuning ▫ Implementation strategies for best
[PDF] pl/sql examples for practice
[PDF] pl/sql implementation
[PDF] pl/sql user's guide and reference 12c pdf
[PDF] place d'armes 78000 versailles
[PDF] place d'armes 78000 versailles frankreich
[PDF] place de la france dans l'économie mondiale
[PDF] place de la france dans l'ue
[PDF] place de la france dans l'union européenne
[PDF] place de la france dans le commerce international
[PDF] place de la france dans le commerce mondial
[PDF] place de la france dans le monde 2018
[PDF] place économique de la france dans le monde
[PDF] place of english as a compulsory subject in school curriculum
[PDF] placement of braille signs
BASEL BERN BRUGG DÜSSELDORF FRANKFURT A.M.
FREIBURG I.BR. GENF HAMBURG KOPENHAGEN LAUSANNEMÜNCHEN
STUTTGART
WIEN ZÜRICH
Do ument Version 3.©201
Trivadis AG
PL/SQL & SQL Coding Guidelines
PL/SQL
& SQLCoding Guidelines
Trivadis AG
Document Version 3.2
©2017 Trivadis AG
PL/SQL & SQL Guidelines
Page | II
This page
intentionally left blankPL/SQL & SQL Guidelines
Page | III
Foreword
In the I.T. world of today, robust and secure applications are becoming more and more important. Many business processes no longer work without I.T. and the dependence of businesses on their I.T. has grown tremendously, meaning we need robust and maintainable applications. An important requirement is to have standards and guidelines, which make it possible to maintain source code created by a number of people quickly and easily. This forms the basis of well functioning off- or on-shoring strategy, as it allows quality assurance to be carried out efficiently at the source. Good standards and guidelines are based on the wealth of experience and knowledge gained from past (and future?) problems, such as those, which can arise in a cloud environment, for exampleUrban Lankes
President of the board of directors
Trivadis
The Oracle Database Developer community is made stronger by resources freely shared by experts around the world, such as the Trivadis Coding Guidelines. If you have not yet adopted standards for writing SQL and PL/SQL in your applications, this is a great place to start.Steven Feuerstein
Oracle Developer Advocate for PL/SQL
Coding Guidelines are a crucial part of software development. It is a matter of fact, that code is more often read than written therefore we should take efforts to ease the work of the reader, which is not necessarily the author. I am convinced that this standard may be a good starting point for your own guidelines.Roger Troller
Principal Consultant Trivadis
PL/SQL & SQL Guidelines
Page | IV
This page
intentionally left blankPL/SQL & SQL Guidelines
Page | V
License
Trademarks
All terms that are known trademarks or service marks have been capitalized. All trademarks are the property of their respective owners.Disclaimer
The authors and publisher shall have neither liability nor responsibility to any person or entity with respect to the loss or damages arising from the information contained in this work. This work may include inaccuracies or typographical errors and solely represent the opinions of the authors. Changes are periodically made to this document without notice. The authors reserve the right to revise this document at any time without notice.Revision History
Version Who Date Comment
0.1 Troller 17.03.2009 Created.
0.2 Kulessa 04.05.2009 Extended.
0.3 Reiner 12.05.2009 Extended with comments in code.
0.4 Troller 14.05.2009 Extended formatting.
0.5 Kulessa 20.05.2009 Added more CodeXpert rules.
0.6 Troller 22.05.2009 Formatting changes. Added categories to
rules.0.7 Reiner 10.06.2009 Extended with example code commenting.
0.8 Troller 18.06.2009 Finalized.
0.9 Bushnell 23.06.2009 Translation
1.0 Troller 01.07.2009 Ready for inspection
1.1 Troller 19.08.2009 Added Inspection results AFl
1.2 Troller 21.08.2009 Added Inspection results ThM
1.3 Troller April 2010 Several Corrections
New Rule Oracle Supplied Packages
1.3.1 Troller October 2010 Some formatting
2.0 Troller August 2011 Added Error Handling Section
Added Rule 23
Added Rule 30
Added Rule 31
Added Rule 43
3.0 Troller 1.2016 Added Rules for ORACLE 12c
Added SQALE Metrics
New guideline numbering system.
3.1 Troller 4.2016 Corrections
3.2 Salvisberg 1.2017 Various small corrections
PL/SQL & SQL Guidelines
Page | 0
PL/SQL & SQL Guidelines
Page | 1
Table of Contents
1.1. Scope ............................................................................................................... 3
1.2. Document Conventions .................................................................................... 3
1.2.1 SQALE characteristics and subcharacteristics .............................................. 3
1.2.2 Severity of the rule ........................................................................................ 5
1.2.3 Keywords used ............................................................................................. 5
1.2.4 Why are standards important ........................................................................ 6
2.1. General Guidelines ........................................................................................... 7
2.2. Naming Conventions for PL/SQL ...................................................................... 8
2.3. Database Object Naming Conventions ............................................................. 9
3. Coding Style ........................................................................................................... 13
3.1. Formatting .......................................................................................................13
3.2. Code Commenting ...........................................................................................14
4. SQL & PL/SQL Language Usage ............................................................................ 16
4.1. General ...........................................................................................................16
4.2. Variables & Types ...........................................................................................27
4.2.1 General ........................................................................................................27
4.2.2 Numeric Data Types ....................................................................................37
4.2.3 Character Data Types ..................................................................................40
4.2.4 Boolean Data Types ....................................................................................44
4.2.5 Large Objects ..............................................................................................45
4.3. DML and SQL ..................................................................................................46
4.3.1 General ........................................................................................................46
4.3.2 BULK OPERATIONS ...................................................................................56
4.4. Control Structures ............................................................................................57
4.4.1 CURSOR .....................................................................................................57
4.4.2 CASE / IF / DECODE / NVL / NVL2 / COALESCE .......................................65
4.4.3 Flow Control ................................................................................................69
4.5. Exception Handling ..........................................................................................86
4.6. Dynamic SQL ..................................................................................................95
4.7. Stored Objects .................................................................................................97
4.7.1 General ........................................................................................................97
4.7.2 Packages ................................................................................................... 103
4.7.3 Procedures ................................................................................................ 111
4.7.4 Functions ................................................................................................... 113
PL/SQL & SQL Guidelines
Page | 2
4.7.5 Oracle Supplied Packages ......................................................................... 119
4.7.6 Object Types ............................................................................................. 120
4.7.7 Trigger ....................................................................................................... 121
4.7.8 Sequences ................................................................................................ 123
4.8. Patterns ......................................................................................................... 124
4.8.1 Checking the Number of Rows .................................................................. 124
4.8.2 Access objects of foreign application schemas .......................................... 126
4.8.3 Validating input parameter size .................................................................. 127
4.8.4 Ensure single execution at a time of a program unit ................................... 129
4.8.5 Use dbms_application_info package to follow progress of a process ......... 131
5. Complexity Analysis ...............................................................................................132
5.1. Halstead Metric ............................................................................................. 132
5.1.1 Calculation ................................................................................................. 132
5.2. Cyclo ............................................................... 133
5.2.1 Description ................................................................................................ 133
6. Code Reviews ........................................................................................................135
7.1. Development ................................................................................................. 136
7.1.1 Setting the preferences .............................................................................. 136
7.1.2 Activate PLSQL Cop using context menu .................................................. 137
7.1.3 Software metrics ........................................................................................ 138
Appendix A Mapping ..................................................................................................140