| Oracle® Database PL/SQL Language Reference 11g Release 2 (11.2) Part Number E10472-02 |
|
|
View PDF |
A record variable is a composite variable whose internal components, called fields, can be of different data types. You access each field with this syntax: record_name.field_name. A record variable can hold a table row, or some columns from a table row. Each field corresponds to a table column.
To create a record variable, you first define a record type, and then declare a variable of that type.
Topics:
Syntax
record_type_definition ::=

field_declaration ::=

See:
record_variable_declaration ::=
Semantics
expression
An expression whose value has a data type compatible with datatype (see Table 3-10, "Possible Implicit PL/SQL Data Type Conversions"). When record_variable_declaration is elaborated, the value of expression is assigned to record_name.field_name. This value is the initial value of the field.
field_name
The name of the field that you are declaring.
NOT NULL
Prevents the program from assigning the value NULL to the field.
PL/SQL subtypes NATURALN, POSITIVEN, and SIMPLE_INTEGER are predefined as NOT NULL. When declaring a field of one of these subtypes, you can omit NOT NULL.
If you declare a NOT NULL field, either by specifying NOT NULL or by specifying a subtype that is predefined as NOT NULL, you must also specify an initial value for the field (see expression).
record_name
The name of the record variable that you are declaring.
type_name
The name of the record type that you are defining.
Examples
Example 5-20, "Assigning Values to VARRAYs with Complex Data Types"
Example 5-21, "Assigning Values to Tables with Complex Data Types"
Example 5-41, "Declaring and Initializing a Simple Record Type"
Example 5-52, "Initializing a Table by Inserting a Record of Default Values"
Related Topics
In this chapter:
In other chapters: