Home

Record fields should comply with a naming convention

Description

    The Pl/SQL code rule "Record fields should comply with a naming convention" means that all record fields should be named in a consistent manner. This helps to ensure that the code is easier to read and understand. It also helps to prevent errors caused by typos or other mistakes. A naming convention could include using all lowercase letters, using underscores to separate words, and using prefixes or suffixes to indicate the data type of the field. Following a naming convention also helps to ensure that the code is consistent and organized.

Key Benefits

  • Consistency: Using a naming convention rule ensures that all record fields are consistently named, making it easier to identify and understand them.
  • Efficiency: Having a standard naming convention rule for record fields can save time and effort when searching for specific data.
  • Accuracy: Following a naming convention rule helps to ensure that records are accurately identified and can be easily retrieved.
  • Simplicity: A naming convention rule simplifies the process of creating and managing records, as it eliminates the need to remember complex names.

 

Non-compliant Code Example

CREATE OR REPLACE PACKAGE BODY CUSTOMER_PACKAGE 
IS
 TYPE CUSTOMER_T IS RECORD
	( FirstName VARCHAR2(50),
	  LastName_ VARCHAR2(50), --Non compliant code (Record fields are not comply with a naming convention)
	  Area VARCHAR2(100),
	  City VARCHAR2(100));
	  
	function GetCompleteCustomerDetails(customerId In INTEGER)
		return CUSTOMER_T 
		Is
		BEGIN
			Select FIRSTNAME, LASTNAME, AREA, CITY Into CUSTOMER_T.FirstName, CUSTOMER_T.LastName, CUSTOMER_T.Area, CUSTOMER_T.City FROM CUSTOMERS Where Id = customerId;
			RETURN CUSTOMER_T; 
	END GetCompleteCustomerDetails;

END CUSTOMER_PACKAGE;

Compliant Code Example

CREATE OR REPLACE PACKAGE BODY CUSTOMER_PACKAGE 
IS
 TYPE CUSTOMER_T IS RECORD
	( FirstName VARCHAR2(50),
	  LastName VARCHAR2(50), --Compliant code (Record fields are comply with a naming convention)
	  Area VARCHAR2(100),
	  City VARCHAR2(100));
	  
	function GetCompleteCustomerDetails(customerId In INTEGER)
		return CUSTOMER_T 
		Is
		BEGIN
			Select FIRSTNAME, LASTNAME, AREA, CITY Into CUSTOMER_T.FirstName, CUSTOMER_T.LastName, CUSTOMER_T.Area, CUSTOMER_T.City FROM CUSTOMERS Where Id = customerId;
			RETURN CUSTOMER_T; 
	END GetCompleteCustomerDetails;

END CUSTOMER_PACKAGE;
Visual Expert 2024
 VEPLSQLRULE117