Named row types

A named row type is a group of fields that are defined under a single name. A field refers to a component of a row type and should not be confused with a column, which is associated with tables only. The fields of a named row type are analogous to the fields of a C-language structure or members of a class in object-oriented programming. After you create a named row type, the name that you assign to the row type represents a unique type within the database. To create a named row type, you specify a name for the row type and the names and data types of its constituent fields. The following example shows how you might create a named row type called person_t:
CREATE ROW TYPE person_t
(
   name     VARCHAR(30) NOT NULL,
   address  VARCHAR(20),
   city     VARCHAR(20),
   state    CHAR(2),
   zip      VARCHAR(9),
   bdate    DATE
);
The person_t row type contains six fields: name, address, city, state, zip, and bdate. When you create a named row type, you can use it just as you would any other data type. The person_t can occur anywhere that you might use any other data type. The following CREATE TABLE statement uses the person_t data type:
CREATE TABLE sport_club
(
   sport     CHAR(20),
   sportnum  INT,
   member    person_t,
   since     DATE,
   paidup    BOOLEAN
)

You can use most data types to define the fields of a row type. For information about data types that are not supported in row types, see Restrictions on named row types.

For the syntax you use to create a named row type, see the CREATE ROW TYPE statement in the HCL OneDB™ Guide to SQL: Syntax. For information about how to cast row type values, see Create and use user-defined casts.