A variable holds a value that can change.
A variable declaration specifies its name, data type, and value, and allocates storage for it. The declaration can also assign an initial value and impose the NOT
NULL
constraint.
Keyword and Parameter Descriptions
A collection (associative array, nested table, or varray) previously declared within the current scope.
A user-defined collection type defined using the data type specifier TABLE
or VARRAY
.
An explicit cursor previously declared within the current scope.
A PL/SQL cursor variable previously declared within the current scope.
A database table or view that must be accessible when the declaration is elaborated.
A database table and column that must be accessible when the declaration is elaborated.
The value to be assigned to the variable when the declaration is elaborated. The value of expression
must be of a data type that is compatible with the data type of the variable.
A constraint that prevents the program from assigning a null value to the variable. Assigning a null to a variable defined as NOT
NULL
raises the predefined exception VALUE_ERROR
.
An instance of an object type previously declared within the current scope.
A user-defined or %ROWTYPE
record previously declared within the current scope.
A field in a user-defined or %ROWTYPE
record previously declared within the current scope.
A user-defined record type that is defined using the data type specifier RECORD
.
A user-defined cursor variable type, defined using the data type specifier REF
CURSOR
.
Represents a record that can hold a row from a database table or a cursor. Fields in the record have the same names and data types as columns in the row.
A predefined scalar data type such as BOOLEAN
, NUMBER
, or VARCHAR2
. Includes any qualifiers for size, precision, and character or byte semantics.
Represents the data type of a previously declared collection, cursor variable, field, object, record, database column, or variable.
The name of the variable. For naming conventions, see Identifiers.
Variables are initialized every time a block or subprogram is entered. By default, variables are initialized to NULL
. Whether public or private, variables declared in a package specification are initialized only once for each session.
An initialization clause is required when declaring NOT
NULL
variables. If you use %ROWTYPE
to declare a variable, initialization is not allowed.