rspec/rules/S2543/plsql/rule.adoc

50 lines
1.2 KiB
Plaintext
Raw Normal View History

2021-04-28 16:49:39 +02:00
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.
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
v1 PLS_INTEGER; -- Noncompliant
v2 VARCHAR2(10);
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
v1 SIMPLE_INTEGER := 42;
v2 VARCHAR2(10);
BEGIN
NULL;
END;
/
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::message.adoc[]
'''
== Comments And Links
(visible only on this page)
include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]