Declaring ROW Variables

ROW variables hold data from named or unnamed ROW types. You can define a generic ROW variable, a named ROW variable, or an unnamed ROW variable.

A generic ROW variable, defined with the ROW keyword, can hold data from any ROW type. A named ROW variable holds data from the named ROW type that you specified in the declaration of the variable.

The following statements show examples of generic ROW variables and named ROW variables:
DEFINE d ROW;               -- generic ROW variable

DEFINE rectv rectangle_t;   -- named ROW variable

A named ROW variable holds named ROW types of the same type in the declaration of the variable.

To define a variable that will hold data stored in an unnamed ROW type, use the ROW keyword followed by the fields of the ROW type, as in:
DEFINE area ROW ( x int, y char(10) );
Unnamed ROW types are type-checked only by structural equivalence. Two unnamed ROW types are considered equivalent if they have the same number of fields, and if the fields have the same type definitions. Therefore, you could fetch either of the following ROW types into the variable area defined above:
ROW ( a int, b char(10) )
ROW ( area int, name char(10) )
ROW variables can have fields, just as ROW types have fields. To assign a value to a field of a ROW variable, use the qualifier notation variableName.fieldName, followed by an expression, as in the following example:
CREATE ROW TYPE rectangle_t (start point_t, length real, width real);

DEFINE r rectangle_t;
      -- Define a variable of a named ROW type
LET r.length = 45.5;
      -- Assign a value to a field of the variable

When you assign a value to a ROW variable, you can use any valid expression.