rspec/rules/S2528/plsql/rule.adoc

49 lines
952 B
Plaintext
Raw Normal View History

== Why is this an issue?
2021-04-28 16:49:39 +02:00
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
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,sql]
2021-04-28 16:49:39 +02:00
----
DECLARE
var1 NUMBER; -- Noncompliant
var2 NUMERIC; -- Noncompliant
BEGIN
NULL;
END;
/
----
=== Compliant solution
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,sql]
2021-04-28 16:49:39 +02:00
----
DECLARE
var1 NUMBER(9,2);
var2 NUMERIC(4,0);
BEGIN
NULL;
END;
/
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Specify the precision for this variable.
endif::env-github,rspecator-view[]