TYPE
Types define a synonym for a base or structured data type.
Syntax:
[PUBLIC|PRIVATE] TYPE identifier type-definition [,...]
{ data-type
| LIKE [dbname:]tabname.colname
}
[ attributes-list ]
FUNCTION (
parameter-name data-type [ attributes-list ]
[,...]
)
[ attributes-list ]
[ RETURNS { data-type [ attributes-list ]
| ( [ data-type [ attributes-list ] [,...] ] )
} ]
ATTRIBUTES ( attribute [ = "value" ] [,...] )
- identifier is the name of the type to be defined.
- 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.
- dbname identifies a specific database schema file.
- tabname.colname references a column defined in the database schema file.
- attribute is an attribute to extend the type definition with properties.
- 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.