RECORD

The RECORD keyword defines a structured type or variable.

Syntax 1 (explicit record definition)

RECORD [ attributes-list ]
  member { data-type
           | LIKE [dbname:]tabname.colname
           }
           [ attributes-list ]
  [,...] 
END RECORD
where attributes-list is:
ATTRIBUTES ( attribute [ = "value" ] [,...] )
  1. member is an identifier for a record member / field.
  2. data-type is a data type, a record definition, a user defined type, an array definition, a built-in class, an imported package class, or a Java class.
  3. dbname identifies a specific database schema file.
  4. tabname.colname references a column defined in the database schema file.
  5. attribute is an attribute to extend the record or record member definition with properties.
  6. value is the value for the record definition attribute, it is optional for boolean attributes.

Syntax 2 (database column based record)

RECORD [ attributes-list ] LIKE [dbname:]tabname.*
where attributes-list is:
ATTRIBUTES ( attribute [ = "value" ] [,...] )
  1. dbname identifies a specific database schema file.
  2. tabname.* references the structure of a complete table defined in the database schema file.
  3. attribute is an attribute to extend the record definition with properties.
  4. value is the value for the record definition attribute, it is optional for boolean attributes.

Usage

A record defines an ordered set of variables called members. Each record member is defined with a specific type or in turn, structured type.

Tip: Consider defining a user type for records, to avoid to repeat the record definition for each variable.

Records whose members correspond in number, order, and data type compatibility to a database table can be useful for transferring data from the database to the screen, to reports, or to functions.

In the first form (Syntax 1), record members are defined explicitly:
DEFINE rec RECORD
           cust_id INT,
           cust_name VARCHAR(50),
           cust_address VARCHAR(100),
           ...
       END RECORD
In the second form (Syntax 2), record members are created implicitly from the table definition found in the database schema file specified by the SCHEMA instruction:
SCHEMA stock
...
DEFINE rec RECORD LIKE customer.*
Important: When using the LIKE clause, the data types are taken from the database schema file during compilation. Make sure that the database schema file of the development database corresponds to the production database, otherwise the records defined in the compiled version of your programs will not match the table structures of the production database. Statements like SELECT * INTO record.* FROM table would fail.