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:
-
record
type
-
%rowtype
-
%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
…