The
KeyExpression property is used to set the different components of a composite key. You can:
- Find out the expression of a composite key (defined in the data model editor or through programming).
- Define the expression of a composite key (when the data file is described through programming).
MyItem1 is Item Description
MyItem2 is Item Description
CompositeKey is Item Description
...
// Declare the item 1
MyItem1.Name = "Item1"
MyItem1.Type = hItemText
MyItem1.Size = 20
HDescribeItem(MyFile1, MyItem1)
// Declare the item 2
MyItem2.Name = "Item2"
MyItem2.Type = hItemText
MyItem2.Size = 20
HDescribeItem(MyFile1, MyItem2)
// Declare the composite key
CompositeKey.Name = "CompItem"
CompositeKey.KeyExpression = "Item1+Item2"
HDescribeItem(MyFile1, CompositeKey)
HDescribeFile(MyFile1)
HCreation(Temp_File)
Syntax
Finding out the expression of a composite key Hide the details
Key expression> = <Data file>.<Item>.KeyExpression
<Key expression>: Character string
Name of the different items included in the composite key. These names of items are separated by the "+" character.
The name of the key item is returned if the key is not a composite key.
<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.
Defining the expression of a composite key Hide the details
<Item>.KeyExpression = <New expression>
<Item>: Character string
Name of the key item used. This name was defined by the Item Description type.
<New expression>: Character string
Name of the different items included in the composite key. These names of items are separated by the "+" character.
Remarks
Describing a composite key item through programming
When describing a composite key item through programming, the
Type property is optional (unlike simple items defined programmatically). However, the composition of the key must be described using the
KeyExpression property.