Oracle PL/SQL - PL/SQL Variable Prefixes Convention


Prefix Variable Type
v_ Local variables declared within a function or procedure
c_ Cursor
r_ Record variable for CURSOR FOR loops
gv_ Global variables declared within a package
gl_ Global constants declared within a package
gc_ Global cursors declared within a package
_yn Pseudo-Boolean items using 'Y'and 'N'for values
_cd Variables restricted to a set of "codes"
_tx All other text formats not covered by cd or yn
_id, _oidVariables to store unique IDs / object IDs
_nr Any numeric datatype not covered by _id or _oid
_dt Date
_ts Timestamp datatype
_tf Boolean variable (TRUE/FALSE values)
_rec Record defined via %ROWTYPE reference to existing table/view/cursor
_ref REF CURSOR defined via SYS_REFCURSOR datatype
_cl CLOB datatype
_bl BLOB datatype
_bf BFILE datatype


The following examples show how you might apply these prefixes and suffixes to create variable names:

Name Description
v_custName_txA variable storing a customer's name
gv_death_dt A global variable storing an employee's death date
v_eval_tf A Boolean evaluation variable

Related Topic