rspec/rules/S2528/plsql/rule.adoc

44 lines
893 B
Plaintext
Raw Normal View History

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++``.
2021-04-28 16:49:39 +02:00
== Noncompliant Code Example
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;
/
----
2021-04-28 16:49:39 +02:00
== Compliant Solution
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)
include::message.adoc[]
endif::env-github,rspecator-view[]