Whenever you declare a variable or a constant, you must assign it a datatype. PL/SQL is, with very few exceptions, a “statically typed programming language” (see the following sidebar for a definition). PL/SQL offers a comprehensive set of predefined scalar and composite datatypes, and you can create your own user-defined types (also known as abstract datatypes). Many of the PL/SQL datatypes are not supported by database columns, such as Boolean and NATURAL, but within PL/SQL code, these datatypes are quite useful.
Virtually all of these predefined datatypes are defined in the PL/SQL STANDARD package. Here, for example, are the statements that define the Boolean datatype and two of the numeric datatypes:
create or replace package STANDARD is type BOOLEAN is (FALSE, TRUE); type NUMBER is NUMBER_BASE; subtype INTEGER is NUMBER(38,);
When it comes to datatypes, PL/SQL supports the “usual suspects” and a whole lot more. This section provides a quick overview of the various predefined datatypes. They are covered in detail in Chapters 8 through 13, Chapter 15, and Chapter 26; you will find detailed references to specific chapters in the following sections.