G-2130: Try to use subtypes for constructs used often in your code.

Minor

Changeability

Reason

Single point of change when changing the data type.

Your code will be easier to read as the usage of a variable/constant may be derived from its definition.

Examples of possible subtype definitions

Type Usage
ora_name_type Object corresponding to the ORACLE naming conventions (table, variable, column, package, etc.).
max_vc2_type String variable with maximal VARCHAR2 size.
array_index_type Best fitting data type for array navigation.
id_type Data type used for all primary key (table_name_id) columns.

Example (bad)

1
2
3
4
5
6
7
8
create or replace package body my_package is
   procedure my_proc is
      l_note varchar2(1000 char);
   begin
      l_note := some_function();
   end my_proc;
end my_package;
/

Example (good)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
create or replace package types is
   subtype big_string_type is varchar2(1000 char);
end types;
/

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