Access row types

supports the SQL row types with the row type host variable. A row type is a complex data type that contains one or more members called fields. Each field has a name and a data type associated with it.

HCL OneDB™ supports the following two kinds of row types:
  • A named row type has a unique name that identifies to a group of fields.
    The named row type is a template for a row definition. You create a named row type with the CREATE ROW TYPE statement. You can then use a named row type as follows:
    • In a column definition of a CREATE TABLE statement to assign the data type for a column in the database
    • In the OF TYPE clause of the CREATE TABLE statement to create a typed table
  • An unnamed row type uses the ROW constructor to define fields.

    You can use a particular unnamed row type as the data type of one column in the database. You create an unnamed row type with the ROW constructor in the column definition of a CREATE TABLE statement.

For more information about row types, see the CREATE ROW TYPE statement in the HCL OneDB Guide to SQL: Syntax and the HCL OneDB Guide to SQL: Reference.

To access a column in a table that has a row type as its data type, perform the following steps:
  1. Declare a row host variable.
  2. Allocate memory for the row host variable with the ALLOCATE ROW statement.
  3. Perform any select or update operations on the row host variable.
  4. Save the contents of the row host variable in the row-type column.