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
DECLARE
v1 PLS_INTEGER; -- Noncompliant
v2 VARCHAR2(10);
BEGIN
NULL;
END;
/
Compliant solution
DECLARE
v1 SIMPLE_INTEGER := 42;
v2 VARCHAR2(10);
BEGIN
NULL;
END;
/