The
Component property configures the different components of a composite key. You can:
- Find out the Nth component of a composite key (defined in the data model editor or through programming).
- Define the Nth component of a composite key (Item Description variable).
// Define the second component of the composite key
LastFirstName.Component[2] = MaidenName
...
// Validate the data file description
HDescribeFile(Customer)
Syntax
Finding out the Nth component of a composite key Hide the details
<Component name> = <Data file>.<Item>.Component[<N>]
<Component name>: Character string
Name of the item corresponding to the sought component of the composite key.
If N = 1 and if <Item> corresponds to a simple key, <Result> corresponds to the key name.
<Data file>: Character string
Name of the data file used. This name was defined in the data model editor or with the File Description type.
<Item>: Character string
Name of the key item used. This name was defined in the data model editor or with the Item Description type.
<N>: Integer
Number of the component whose name is requested. The number of elements in a composite key is returned by the NbComponent property.
Defining the Nth component of a composite key Hide the details
<Item>.Component[<N>] = <New component name>
<Item>: Character string
Name of the key item used. This name was defined by the Item Description type.
<N>: Integer
Number of the component that must be modified or added. The number of elements in a composite key is returned by the NbComponent property.
<New component name>: Character string
Name of the item that must be used as component of the composite key.
Remarks
Modifying a composite key
Modifying a composite key may allow you to add new components to the composite key during its description through programming. The different components must be numbered in ascending order and no "empty" slot must be found (for example, you cannot go from component 4 to component 6). Otherwise, a WLanguage error occurs.
Remark: It is recommended to use the
KeyExpression property to build a composite key in the code.
Error management
A fatal error (WLanguage error) occurs in the following cases:
- requested component greater than the number of components found in the key,
- writing a component that does not immediately follow the last component of the composite key.