rules repository

G-9102

🆓
Warning

Always follow naming conventions for local variables.

Reason

PL/SQL identifiers share the same namespace as SQL identifiers. Follow naming conventions to prevent naming conflicts, improve readability, and clearly indicate the scope without forcing the use of qualified names. A common practice is to use a prefix and/or suffix to distinguish the identifier types.

General local variables that are not based on a cursor, record, collection type or object type. However, this rules accepts patterns for cursor variables (G-9103), record variables (G-9104), collection variables (G-9105) and object variables (G-9106).

Example

Non-Compliant Example

declare
   some_name integer;
begin
   null;
end;
/
Issues
LineColumnMessage
24Local variable some_name does not match '(?i)^l_[a-z0-9$#_]+$'.

Compliant Solution - ★★★★★

declare
   l_some_name integer;
begin
   null;
end;
/

Parameters

Use parameters to customize the rule to your needs.

ParameterDescriptionDefault Value
ObjectTypesComma-separated list of unqualified database object types. If empty, the installed object types are used.,
CollectionPatternRegular expression pattern for PL/SQL local variables of type array/table.(?i)^t_[a-z0-9$#_]+$
ObjectPatternRegular expression pattern for PL/SQL local variable of SQL object type.(?i)^o_[a-z0-9$#_]+$
CollectionTypesComma-separated list of unqualified database collection types. If empty, the installed collection types are used.,
LocalVariablePatternRegular expression pattern for PL/SQL common local variables.(?i)^l_[a-z0-9$#_]+$
RecordPatternRegular expression pattern for PL/SQL local variables of type record.(?i)^r_[a-z0-9$#_]+$
CursorPatternRegular expression pattern for PL/SQL local variables of type cursor.(?i)^c_[a-z0-9$#_]+$

References