Home
Variables Naming Convention
Description
The Pl/SQL Variables Naming Convention is a set of rules for naming variables in the Pl/SQL programming language. This convention helps to ensure that variables are named in a consistent and logical manner, making code easier to read and understand. The convention states that all variables should be named using only alphanumeric characters, and should begin with a letter. Variables should also be named in a descriptive manner, using words that accurately describe the purpose of the variable. Additionally, variables should be named using a combination of lowercase and uppercase letters, with the first letter of each word in the variable name being uppercase. This helps to make the variable name more readable and easier to understand.
Key Benefits
- Ease of Understanding: Variables Naming Convention rule makes it easier for developers to understand the code by providing a clear and consistent way of naming variables.
- Reduced Errors: By following the Variables Naming Convention rule, it reduces the chances of errors due to incorrect naming of variables.
- Improved Readability: Following the Variables Naming Convention rule helps to improve the readability of the code, making it easier to read and debug.
- Better Collaboration: Variables Naming Convention rule makes it easier for developers to collaborate on a project, as everyone is using the same conventions.
Non-compliant Code Example
DECLARE
CURSOR curs_customer_(customer_name VARCHAR2) RETURN customer%ROWTYPE; --Non compliant code (Variable is not comply with the naming convention)
CURSOR curs_customer(customer_name VARCHAR2) RETURN customer%ROWTYPE IS SELECT * FROM CUSTOMERS WHERE name = customer_name;
BEGIN
NULL;
END;
Compliant Code Example
DECLARE
CURSOR curs_customer1(customer_name VARCHAR2) RETURN customer%ROWTYPE; --Compliant code (Variable is comply with the naming convention)
CURSOR curs_customer2(customer_name VARCHAR2) RETURN customer%ROWTYPE IS SELECT * FROM CUSTOMERS WHERE name = customer_name;
BEGIN
NULL;
END;