Home

Positional and named arguments should not be mixed in invocations

Description

    The rule "Positional and named arguments should not be mixed in invocations" states that when invoking a PL/SQL procedure or function, all arguments should either be passed in using their position in the argument list, or all arguments should be passed in using their named parameters. Mixing positional and named arguments in the same invocation is not allowed.

Key Benefits

  • Easier to read: Positional and named arguments should not be mixed in invocations as it makes the code easier to read and understand.
  • More maintainable: Mixing positional and named arguments can make code more difficult to maintain and debug, as it can be hard to keep track of which argument is which.
  • More consistent: Using either positional or named arguments consistently makes the code more consistent and easier to follow.

 

Non-compliant Code Example

CREATE PROCEDURE GetTotalExpense(invoice_amount1 NUMBER,invoice_amount2 NUMBER)
As
BEGIN
	DBMS_OUTPUT.PUT('Total expense amount is'|| (invoice_amount1 + invoice_amount2));
END;

BEGIN
	GetTotalExpense(1520,invoice_amount2=>633); --Non compliant code (Positional and named arguments are mixed in the invocations)
	GetTotalExpense(invoice_amount1=>1520,633); --Non compliant code (Positional and named arguments are mixed in the invocations)
END;

Compliant Code Example

CREATE PROCEDURE GetTotalExpense(invoice_amount1 NUMBER,invoice_amount2 NUMBER)
As
BEGIN
	DBMS_OUTPUT.PUT('Total expense amount is'|| (invoice_amount1 + invoice_amount2));
END;

BEGIN
	GetTotalExpense(1520,633);
	GetTotalExpense(invoice_amount1=>1520,invoice_amount2=>633); --Compliant code (Positional and named arguments are separates in invocations)
END;
Visual Expert 2024
 VEPLSQLRULE29