G-9105
🆓Always follow naming conventions for collection variables (arrays/tables).
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.
Local variables for a collection type (array/table). Can only be distinguished from general local variables if PL/SQL collection types are declared in the same file. For SQL collection types, the list of SQL collection types must be provided as a static list or retrieved from the Data Dictionary.
Example
Non-Compliant Example
declare type t_varray_type is varray(10) of string; array1 t_varray_type; type t_nested_table_type is table of string; array2 t_nested_table_type; type t_assoc_array_type is table of string index by pls_integer; array3 t_assoc_array_type; begin null; end; /
Issues
Line | Column | Message |
---|---|---|
3 | 4 | |
5 | 4 | |
7 | 4 |
★★★★★
Compliant Solution -
declare type t_varray_type is varray(10) of string; t_array1 t_varray_type; type t_nested_table_type is table of string; t_array2 t_nested_table_type; type t_assoc_array_type is table of string index by pls_integer; t_array3 t_assoc_array_type; begin null; end; /
Parameters
Use parameters to customize the rule to your needs.
Parameter | Description | Default Value |
---|---|---|
CollectionTypes | Comma-separated list of unqualified database collection types. If empty, the installed collection types are used. | , |
CollectionPattern | Regular expression pattern for PL/SQL local variables of type array/table. | (?i)^t_[a-z0-9$#_]+$ |
References
- similar to plsql:NamingVariablesCheck
The scope of plsql:NamingVariablesCheck is all variables, not just collection variables.