42.4. Data Types

42.4.1. The SQL data types
42.4.2. PLS_INTEGER
42.4.3. STRING

Every pl/sql constant, variable, parameter, and function return value has a data type that determines its storage format and its valid values and operations. This chapter explains scalar data types. A scalar data type can have domain. A domain has the same valid operations as its base type. A data type and its domains comprise a data type family. pl/sql predefines many types and domains, there are:

42.4.1. The SQL data types

The built-in base types are described in Chapter 9.

42.4.2. PLS_INTEGER

The pl/sql data types PLS_INTEGER and INT4 are identical. The PLS_INTEGER data type stores signed integers in the range -2,147,483,648 through 2,147,483,647, represented in 32 bits.

A calculation with two PLS_INTEGER values that overflows the PLS_INTEGER range raises an overflow exception. For example, use an anonymous block to raises an overflow:

DECLARE
    p1 PLS_INTEGER := 2147483647;
    p2 PLS_INTEGER := 1;
    n NUMBER;
BEGIN
    n := p1 + p2;
END;
/
            

42.4.3. STRING

The VARCHAR2 data type has one predefined domain in pl/sql, named STRING.

The STRING data type can be used for function or procedure parameters. For example:

CREATE OR REPLACE PROCEDURE testP(p1 IN STRING, p2 IN NUMBER) AS
BEGIN
    DBMS_OUTPUT.SERVEROUTPUT(true);
    DBMS_OUTPUT.PUT_LINE(p1 || p2);
END;
/

CALL testP('string', 123);
            

The STRING data type support type modifier in pl/sql. For example:

DECLARE
    p STRING(10) := 'str';
BEGIN
    DBMS_OUTPUT.SERVEROUTPUT(true);
    DBMS_OUTPUT.PUT_LINE(p || 'ing');
END;
/