 |
|
PL/SQL code alignment standards
Oracle Tips by Jonathan Ingram
|
Alignment of PL/SQL Operators
These guidelines enhance the readability of code by adding white space and
clarifying complex expressions.
? Arrange series of
statements containing similar operators into columns whenever it will not cause
excessive white space and you have sufficient room to do so.
Correct:
vFirstName := 'Roger';
vLastName := 'Smith';
vSSN := 999999999;
Incorrect:
vFirstName := 'Roger';
vLastName := 'Smith';
vSSN := 999999999;
? Always use parentheses
in expressions containing more than one identifier or literal. This clarifies
code for inexperienced developers who are not familiar with operator precedence
and helps eliminate the possibility that you?ve overlooked something in your
equation.
Correct:
IF (nSSN < 2.5) THEN
<statements>
END IF;
Incorrect:
IF nSSN < 2.5 THEN
<statements>
END IF;
? Align the IN and
OUT keywords in columns when defining the interface for a procedure or
function.
Correct:
PROCEDURE Days_Between (dStartDate IN date,
dEndDate IN date,
nGPA IN OUT number,
nDaysBetween OUT number)
<procedure declarations and body>
Incorrect:
PROCEDURE Days_Between (dStartDate IN date,
dEndDate IN date,
nGPA IN OUT number,
nDaysBetween OUT number)
<procedure declarations and body>
? When calling a
procedure or function, align the parameters into a column. This reduces the
visual clutter around the call, making it stand out from the rest of the code.
Correct:
DaysBetween (dStartDate => dEnrolledDate,
dEndDate => dGraduationDate,
nGPA => nFinalGPA,
nDaysBetween => nDuration);
Incorrect:
DaysBetween (dStartDate => dEnrolledDate,
dEndDate => dGraduationDate,
nGPA => nFinalGPA,
nDaysBetween => nDuration);
This is an excerpt from "High Performance Oracle Database
Automation", by Jonathan Ingram and Donald K. Burleson, Series Editor.