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 (id) columns. |
Example (bad)
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)
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();
END my_proc;
END my_package;
/