User-defined record types and record variables v15
You can declare records based on a table definition using the
%ROWTYPE attribute, as shown in Using %ROWTYPE in record declarations. You can also define a new record structure that isn't tied to a particular table definition.
You use the
TYPE IS RECORD statement to create the definition of a record type. A record type is a definition of a record made up of one or more identifiers and their corresponding data types. You can't use a record type by itself to manipulate data.
The syntax for a
TYPE IS RECORD statement is:
fields is a comma-separated list of one or more field definitions of the following form:
rec_typeis an identifier assigned to the record type.
field_nameis the identifier assigned to the field of the record type.
data_typespecifies the data type of
DEFAULTclause assigns a default data value for the corresponding field. The data type of the default expression must match the data type of the column. If you don't specify a default, then the default is
A record variable or record is an instance of a record type. A record is declared from a record type. The properties of the record such as its field names and types are inherited from the record type.
The following is the syntax for a record declaration:
record is an identifier assigned to the record variable.
rectype is the identifier of a previously defined record type. Once declared, you can't then use a record to hold data.
Use dot notation to reference the fields in the record:
record is a previously declared record variable and
field is the identifier of a field belonging to the record type from which
record is defined.
emp_sal_query procedure uses a user-defined record type and record variable:
Instead of specifying data type names, you can use the
%TYPE attribute for the field data types in the record type definition.
The following is the output from executing this stored procedure: