rules repository

G-2120

πŸ†“
Warning

Try to have a single location to define your types.

Variable β€’ Check

Reason

Single point of change when changing the data type. No need to argue where to define types or where to look for existing definitions.

A single location could be either a type specification package or the database (database-defined types).

Example

Non-Compliant Example

create or replace package body my_package is
   procedure my_proc is
      subtype big_string_type is varchar2(1000 char);
      l_note big_string_type;
   begin
      l_note := some_function();
      do_something(l_note);
   end my_proc;
end my_package;
/
Issues
LineColumnMessage
315Locally defined subtype big_string_type.

Compliant Solution - β˜…β˜…β˜…β˜…β˜…

create or replace package types_up is
   subtype big_string_type is varchar2(1000 char);
end types_up;
/

create or replace package body my_package is
   procedure my_proc is
      l_note types_up.big_string_type;
   begin
      l_note := some_function();
      do_something(l_note);
   end my_proc;
end my_package;
/

References