Declaring a NUMBER
variable without any precision wastes memory because Oracle supports up to 38 decimal digits by default (or the
maximum supported by your system, whichever is less). If you don’t need that large a value, you should specify whatever matches your needs. This will
save memory and provide extra integrity checking on input.
This rule also applies to some NUMBER
subtypes as well: NUMERIC
, DEC
, and DECIMAL
.
Noncompliant code example
DECLARE
var1 NUMBER; -- Noncompliant
var2 NUMERIC; -- Noncompliant
BEGIN
NULL;
END;
/
Compliant solution
DECLARE
var1 NUMBER(9,2);
var2 NUMERIC(4,0);
BEGIN
NULL;
END;
/