Skip to content

G-7330: Always assign values to OUT parameters.

Major

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
create or replace package body my_package is
   procedure greet(
      in_name      in  varchar2
     ,out_greeting out varchar2
   ) is
      l_message varchar2(100 char);
   begin
      l_message := 'Hello, ' || in_name;
   end greet;
end my_package;
/

Example (good)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
create or replace package body my_package is
   procedure greet(
      in_name      in  varchar2
     ,out_greeting out varchar2
   ) is
   begin
      out_greeting := 'Hello, ' || in_name;
   end greet;
end my_package;
/