 |
|
PL/SQL variable naming standards
Oracle Tips
Coriolis Publishing
|
Oracle Program Identifier
Standards
When declaring variables and constants, the developer should preface a
meaningful identifier with one of the prefixes shown below:
|
Datatype prefixes for use in identifiers.
|
|
Datatype |
Prefix |
Example |
|
binary_integer |
bi |
biArrayIndex |
|
boolean |
b
|
bStudentQualifiesForAid |
|
char |
c
|
cYesOrNo |
|
date |
d
|
dEnrolledDate |
|
exception |
x
|
xTABLE_DOES_NOT_EXIST |
|
integer |
i
|
iCoursesCarried |
|
long |
l
|
lComments |
|
longraw |
lr |
lrStudentPhoto |
|
natural |
na |
naArrayIndex |
|
number |
n
|
nRemainingBalance |
|
raw |
r
|
rStudentPhoto |
|
rowid |
row |
rowStudent |
|
varchar2 |
v
|
vStudentFirstName |
|
|
|
Identifiers should always use mixed-case and capital letters to indicate
separation of elements within an identifier. Thus, a variable of type
varchar2 that holds a student’s first name would be vStudentFirstName.
The identifiers used for explicitly declared cursors should be meaningful;
the suffix _cur should be appended to the identifier. For example:
CURSOR Students_cur
IS
SELECT first_name, middle_name, last_name, overall_gpa, most_recent_gpa
FROM STUDENTS;
Identifiers declared using %TYPE should still include a datatype
prefix as part of the identifier name:
nStudentSSN STUDENTS.ssn%TYPE;
Identifiers declared using %ROWTYPE should be named like the object
that is lending the variable its structure. These identifiers should always
include the _rec suffix as part of the identifier:
Students_rec STUDENTS%ROWTYPE;
FailingStudents_rec FailingStudents_cur%ROWTYPE;
This is an excerpt from "High Performance Oracle Database
Automation", by Jonathan Ingram and Donald K. Burleson, Series Editor.