Home
Parameter IN mode should be specified explicitly
Description
The rule "Parameter IN mode should be specified explicitly" states that when writing PL/SQL code, all parameters passed to a procedure or function must be explicitly declared as either IN or OUT parameters. This ensures that the code is clear and easy to understand, and that any potential errors are avoided. By explicitly declaring the mode of the parameter, the code is more self-documenting and easier to debug.
Key Benefits
- Explicitness: Parameter IN mode should be specified explicitly, providing clarity and reducing the risk of errors.
- Consistency: This rule ensures that all parameters are declared in a consistent manner, making code easier to read and maintain.
- Flexibility: This rule allows for greater flexibility when declaring parameters, allowing for more control over the behavior of the code.
Non-compliant Code Example
function GetCompleteCustomerDetails(customerId INTEGER) --Non compliant code (Parameter IN mode is not specified)
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;
Compliant Code Example
function GetCompleteCustomerDetails(customerId In INTEGER) --Compliant code (Parameter IN mode specified)
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;