Plsql regle de codificat

6927 mots 28 pages
Some Naming and Coding Standards

April 25, 2000

**DRAFT **

Table of Contents

Table of Contents 2
Introduction 3 Benefits of Having Standards 3 Format of this Document 3
File naming conventions 3
Identifier naming conventions 4 Scope 4 Type 4 Primary Identifier 5 Modifier 5 Suffix 5
Variable Usage Conventions 5 Cursor Declarations 6 FOR loop index 6 PL/SQL table TYPE 7 Programmer-defined subtype 7 PL/SQL Record TYPE 7
Code format 8 Indentation 8 Using Case to Aid Readability 9 Formatting Single Statements 9 Formatting Declarations 10 Formatting Multiline Statements 10
Commenting style 11 Comment As you Code 11 Explain Why - Not the How 11 Make Comments Easy to Enter and Maintain 11 Maintain Indentation 11
Syntax Guidelines 11 Branching and Labels 11 Conditional Statements 12 REPETITION 14 Avoid Unstructured Exits from Loops 18 Do not use PL/SQL where you can use a SQL statement instead. 18
PL/Sql Programming Guidelines 18 Use Named Constants to Avoid Hard-coding Values 18 Convert Variables into Named Constants 19 Avoid the recycling of variables 19 Name Subtypes to Self-document Code 19 Remove Unused Variables from Programs 20 Use %TYPE when a variable represents a column 20 Use %TYPE to standardize non-database declarations 20 Use Variables to hide complex logic 21 Building from high-level rules 22 Converting pseudo-code to PL/SQL 23
SQL Guidelines 25 Right align the reserved words 25 Don’t skimp on line seperators 25 Use sensible abbreviations for table and column aliases 26


The first and most important thing about standards is to have them. Once you sit down and come up with a set of standards then it becomes very easy to follow them. Remember when you first learned to drive! It seemed to take up all your attention just to keep the car going straight ahead. But now you probably do not even think about

en relation