Use a named row type within another row type
You can use a named row type as the data type of a field within another row type. A nested row type is a row type that contains another row type. You can nest any row type within any other row type. No practical limit exists on how deeply you can nest row types. However, to perform inserts or updates on deeply nested row types requires careful use of the syntax.
For named row
types, the order in which you create the row types is important because
a named row type must exist before you can use it to define a column
or a field within another row type. In the following example, the
first statement creates the address_t type, which is used in
the second statement to define the type of the address field
of the employee_t type:
CREATE ROW TYPE address_t
(
street VARCHAR (20),
city VARCHAR(20),
state CHAR(2),
zip VARCHAR(9)
);
CREATE ROW TYPE employee_t
(
name VARCHAR(30) NOT NULL,
address address_t,
salary INTEGER
);
Important: You cannot use a row type recursively.
If type_t is a row type, then you cannot use type_t as
the data type of a field contained in type_t.