rules repository

G-7330

🆓
Error

Always assign values to OUT parameters.

Reason

Marking a parameter for output means that callers will expect its value to be updated with a result from the execution of the procedure. Failing to update the parameter before the procedure returns is surely an error.

Example

Non-Compliant Example

create or replace package body my_package is
   procedure greet(
      in_name      in  varchar2
     ,out_greeting out varchar2
   ) is
      l_message types_up.text;
      co_name   constant employees.first_name := in_name;
      co_hello  constant types_up.text        := 'Hello, ';
   begin
      l_message := co_hello || co_name;
   end greet;
end my_package;
/
Issues
LineColumnMessage
47No value assigned to OUT parameter out_greeting.

Compliant Solution - ★★★★★

create or replace package body my_package is
   procedure greet(
      in_name      in  varchar2
     ,out_greeting out varchar2
   ) is
      co_name  constant employees.first_name := in_name;
      co_hello constant types_up.text        := 'Hello, ';
   begin
      out_greeting := co_hello || co_name;
   end greet;
end my_package;
/

References