rules repository

G-7410

🆓
Warning

Avoid standalone functions – put your functions in packages.

Stored Object • Check

Reason

Use packages to structure your code, combine procedures and functions which belong together.

Package bodies may be changed and compiled without invalidating other packages. This is a major advantage compared to standalone procedures and functions.

Example

Non-Compliant Example

create or replace function my_function return varchar2
   deterministic
is
begin
   return null;
end my_function;
/
Issues
LineColumnMessage
128Put my_function in a package.

Compliant Solution - ★★★★★

create or replace package body my_package is
   function my_function return varchar2
      deterministic
   is
   begin
      return null;
   end my_function;
end my_package;
/

References