Skip to content

G-7330: Always assign values to OUT parameters.

Blocker

Maintainability, Testability

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 (bad)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
create or replace package body my_package is
   procedure greet(
      in_name      in  varchar2
     ,out_greeting out varchar2 -- violates also G-7150
   ) 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; -- NOSONAR: G-2135
   end greet;
end my_package;
/

Example (good)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
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;
/