Version 4.0
https://trivadis.github.io/plsql-and-sql-coding-guidelines/v4.0/
PLSQL-and-SQL-Coding-Guidelines.pdf
Breaking Changes
- #57 - Changed Code Style Rule 1 from “Keywords are written uppercase, names are written in lowercase“ to "Keywords and names are written in lowercase”
- added reason for this change
- updated all code examples
- #81 - Removed G-7240 (Avoid using an IN OUT parameter as IN or OUT only) and replaced it with these rules:
- G-7160: Always explicitly state parameter mode.
- G-7170: Avoid using an IN OUT parameter as IN or OUT only.
New
- #28 - G-1080: Avoid using the same expression on both sides of a relational comparison operator or a logical operator.
- #48 - G-2135: Avoid assigning values to local variables that are not used by a subsequent statement.
- #34 - G-2145: Never self-assign a variable.
- #54 - G-2610: Never use self-defined weak ref cursor types.
- #34 - G-3115: Avoid self-assigning a column.
- #26 - G-3185: Never use ROWNUM at the same query level as ORDER BY.
- #38 - G-3195: Always use wildcards in a LIKE clause.
- #22 - G-3310: Never commit within a cursor loop.
- #22 - G-3320: Try to move transactions within a non-cursor loop into procedures.
- #31 - G-4250: Avoid using identical conditions in different branches of the same IF or CASE statement.
- #44/#90 - G-4260: Avoid inverting boolean conditions with NOT.
- #45 - G-4270: Avoid comparing boolean values to boolean literals.
- #50 - G-4325: Never reuse labels in inner scopes.
- #36 - G-5080: Always use FORMAT_ERROR_BACKTRACE when using FORMAT_ERROR_STACK or SQLERRM.
- #35 - G-7125: Always use CREATE OR REPLACE instead of CREATE alone.
- #25 - G-7250: Never use RETURN in package initialization block.
- #30 - G-7330: Always assign values to OUT parameters.
- #27 - G-7720: Never use multiple UPDATE OF in trigger event clause.
- #84 - G-7730: Avoid multiple DML events per trigger if primary key is assigned in trigger.
- #40 - G-9010: Always use a format model in string to date/time conversion functions.
- #40 - G-9020: Try to use a format model and NLS_NUMERIC_CHARACTERS in string to number conversion functions.
- #40 - G-9030: Try to define a default value on conversion errors.
- #88/#89 - Added "Unsupported in PL/SQL Cop Validators” section for every guideline without validator in PL/SQL Cop
Changed
- #77 - G-5040: Added exception for logging framework calls
- #78 - G-1050: Added exception for logging framework calls
- #79 - G-7230: Added exception for constants
- #85 - G-4220: Added warning regarding different NULL handling in DECODE and CASE
- #93/#98 - Updated Appendix B with changed/new rules
- #95 - Updated trivadis/mktools docker image
- #97 - Included Material for MkDocs 6.0 in trivadis/mktools docker image
Fixed
Version 3.4
https://trivadis.github.io/plsql-and-sql-coding-guidelines/v3.4/
PLSQL-and-SQL-Coding-Guidelines.pdf
New
- #55 - Added naming conventions for check constraints (
_ck
suffix) - #56 - Added section "We do not agree with all your standards" in introduction chapter
- #56 - Added footnote for tables, views; explaining why we use plurals in naming conventions chapter
- #56 - Added footnote for indention; explaining why we use 3 spaces in coding style chapter
- #70 - Extended naming conventions for views and tables regarding EBR (
_eb
suffix)
Improved
- #4 - Renamed the use of "ANSI-join" to "ANSI SQL-92 join" (title and reason in G-3130)
- #7 - Renamed G-8420 to G-8510 to follow numbering rules (new chapter)
- #14 - Do not wrap lines in code blocks on devices with small screen widths
- #61 - Add explanation to good example of G-3150 regarding
GENERATED ALWAYS AS IDENTITY
- #62 - Renamed G-3160 from
"Avoid virtual columns to be visible" to
"Avoid visible virtual columns" - #63 - Add char semantic in column of G-3170
- #64 - Improved formatting of bad example in G-4220 (
decode
) - #67 - Renamed G-8410 from
"Always use application locks to ensure a program unit only running once at a given time" to
"Always use application locks to ensure a program unit is only running once at a given time" - Updated Trivadis logo (without slogan "makes IT easier")
Fixed
- #18 - Example uses one parameter, G-7110 is applied only for two and more parameters
- #20 - Added missing
G-
prefix in G-7320 - #21 - Incomplete good and bad examples in G-8410
- #65 - Broken link in G-4310, McConnell, Steve C. (2004). Code Complete. Second Edition. Microsoft Press.
- #66 - Grammar in bad example of G-5030
- #67 - Wrong parameter in bad example of G-8410 (
in_lock_handle
instead ofin_lock_name
) - #68 - Typo in reason of G-8510
Version 3.0
PLSQL-and-SQL-Coding-Guidelines.pdf
- Release in January 2016
- Added rules for Oracle Database 12c
- Added SQALE metrics
- New guideline numbering system
Version 2.0
PLSQL-and-SQL-Coding-Guidelines.pdf
- Released in August 2011
- Added error handling section
- Added rule 23: Always define your VARCHAR2 variables using CHAR SEMANTIC
- Added rule 30: Use BULK OPERATIONS (BULK COLLECT, FORALL) whenever you have to
repeatedly execute a DML or SELECT command for more than 4 times. - Added rule 31: Always use %NOTFOUND instead of NOT %FOUND to check whether a cursor was
successful. - Added rule 43: Use 1 as lower boundary and COUNT() as upper boundary when looping over a
dense array.