rspec/rules/S2543/plsql/rule.adoc
Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
Inline adoc files when they are included exactly once.

Also fix language tags because this inlining gives us better information
on what language the code is written in.
2023-05-25 14:18:12 +02:00

57 lines
1.5 KiB
Plaintext

== Why is this an issue?
ORACLE 11g introduced the ``++SIMPLE_INTEGER++`` data type, which is a sub-type of ``++PLS_INTEGER++``, and covers the same range. There are three main differences between the two types:
* ``++SIMPLE_INTEGER++`` is always ``++NOT NULL++``. So when the value of the declared variable is never going to be null, you can declare it as ``++SIMPLE_INTEGER++``.
* You will never face a numeric overflow using ``++SIMPLE_INTEGER++`` because this data type wraps around without giving any error.
* The ``++SIMPLE_INTEGER++`` data type gives a major performance boost over ``++PLS_INTEGER++`` when the code is compiled in "NATIVE" mode, because arithmetic operations on ``++SIMPLE_INTEGER++`` type are performed directly at the hardware level.
=== Noncompliant code example
[source,sql]
----
DECLARE
v1 PLS_INTEGER; -- Noncompliant
v2 VARCHAR2(10);
BEGIN
NULL;
END;
/
----
=== Compliant solution
[source,sql]
----
DECLARE
v1 SIMPLE_INTEGER := 42;
v2 VARCHAR2(10);
BEGIN
NULL;
END;
/
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Convert this variable to a "SIMPLE_INTEGER".
'''
== Comments And Links
(visible only on this page)
=== on 27 Jul 2017, 13:50:22 Ann Campbell wrote:
\[~michal.budzowski] there is a clash between this rule and RSPEC-4081, but RSPEC-4081 wasn't on by default. Nonetheless, I've removed this one from the default profile.
endif::env-github,rspecator-view[]