Search notes:

Oracle PL/SQL: RECORD

A record is a tuple with a predefined number of named fields each of which has a data type that is independant from that of other fields.
Thus, a record is fundamentally different from collection types that stores zero, one or more elements of the same data type.
When a record variable is initialized, the initial value of each field is null unless a different initial value was declared for it when the record type was defined.

Creating records

There are three ways to create a record type:
It is not possible to create a record type at schema level.

Default values

declare
   type rec is record (
      fld_one varchar2(10) default 'foo',
      fld_two varchar2(10) default 'bar
      …',
    );
    …

%rowtype

%rowtype can be used to create a record type that represents a row in a table.
declare
   tab_rec tab%rowtype;
   …
%rowtype can also be used to create a record that matches the fields in a cursor:
declare
   cursor cur_xyz is select … from tab;

   rec_cur cur_xyz%rowtype
   …

Assigning null to a record variable

Assigning null to a record variable sets all its fields to null.

Collections

It is possible for a record-field to contain a collection type.

Index