TYPES - key
Syntax
... [UNIQUE | NON-UNIQUE] { {KEY comp1 comp2 ...}
| {DEFAULT KEY} } ... .
Effect
Definition of a table key in an internal table.
You use UNIQUE and NON-UNIQUE
to specify whether the table key is unique or not. For a table key specified with
UNIQUE, a row with a certain key field content can only occur once in an internal table of this type. You can only use NON-UNIQUE for
standard tables, you have to use UNIQUE for
hashed tables, and both for sorted tables.
The key fields can be alternatively defined as follows:
-
Bulleted list of individual components comp1 comp2 ...
of the row type behind KEY. Prerequisite is that the row type is structured and that the components are neither table types nor table types containing components.
-
If the entire table row is defined as a key, you can only specify the
pseudo component
table_line behind KEY as the only component comp. This is possible for any row types.
-
Specify the standard key DEFAULT KEY. The standard key fields of a structured row type are all fields that are neither numeric
(i, p,
f) nor table types. The standard key for non-structured row types is the entire table row
if the row type itself is not a table type. If there is no relevant component that applies and the row type itself is a table type, the standard key remains empty. This is only possible for standard tables.
The table key does not have to be specified in the statement TYPES
and does not have to be unique. If a table key is not or only partially specified, then the resulting table type is generic and can only be used for
typing formal parameters or field symbols. The individual table types are differentiated as follows:
-
If no key is specified for standard tables, the table type to the key fields is generic. The addition NON-UNIQUE is always implicitly extended for standard tables.
-
If no key is specified for sorted tables, the table key is completely generic. If only the additions
UNIQUE and NON-UNIQUE are omitted, the table key is only generic in regards to uniqueness.
-
If no key is specified for hashed tables,
the table key is completely generic. If a key is specified, then addition UNIQUE must be specified.
-
For the generic table types ANY
TABLE and INDEX TABLE, you can specify a key without specifying the uniqueness.