TYPE

Types define a synonym for a base or structured data type.

Syntax:

[PUBLIC|PRIVATE] TYPE identifier type-definition [,...]
where type-definition is:
{ data-type
| LIKE [dbname:]tabname.colname
}
   [ attributes-list ]
or type-definition is a function type definition:
FUNCTION function-name (
     parameter-name data-type [ attributes-list ]
     [,...]
  )
 [ attributes-list ]
 [ RETURNS { data-type [ attributes-list ]
             | ( [ data-type [ attributes-list ] [,...] ] )
             } ]
where attributes-list is:
ATTRIBUTES ( attribute [ = "value" ] [,...] )
  1. identifier is the name of the type to be defined.
  2. data-type can be a primitive data type, a record structure, an array definition, a dictionary 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 type definition with properties.
  6. value is the value for the type attribute, it is optional for boolean attributes.

Usage

User-defined types enforce reusability and simplify programming, by centralizing data structure definitions at a single place.

When defining types with the LIKE clause, the data types are taken from the database schema file at compile time. Make sure that the schema file of the database schema during development corresponds to the database schema of the production database; otherwise the types defined in the compiled version of your modules will not match the table structures of the production database.

Types referencing data types can use the ATTRIBUTES() clause, to specify meta-data information for the type member. This feature is especially used when defining types for XML-based Web Services. For more details about XML attributes, see Attributes to customize XML serialization.

Function reference types can be used to define program variables, that will hold a function reference. See Function references for more details.