Skip to content

G-7440: Never use OUT parameters to return values from a function.

Major

Reusability

Reason

A function should return all its data through the return clause. Having an out parameter prohibits usage of a function within SQL statements.

Example (bad)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
create or replace package body my_package is
   function my_function(out_date out date) return boolean
      deterministic
   is
   begin
      out_date := sysdate;
      return true;
   end my_function;
end my_package;
/

Example (good)

1
2
3
4
5
6
7
8
9
create or replace package body my_package is
   function my_function return date
      deterministic
   is
   begin
      return sysdate;
   end my_function;
end my_package;
/