Adding a record containing a composite key
When adding or modifying a record containing a composite key, the value of the composite key is automatically defined according to the values of the different key components. No specific programming is required.
Adding a record containing a composite key into a linked file
When a record containing a composite key is added into a linked file, the value of the key must be built. Indeed, in the linked file, the composite key is not considered as being a composite key but as being a binary key. Therefore, a value must be assigned to it.
This value can be assigned:
- directly. For example, a record was added into the Customer file. To add the value of the key into the linked file, all you have to do is perform a direct assignment:
- via H创建键值. This function is used to build the value of the composite key from its components.
Building the value of a composite key to implement a search or a filter
When a filter or a search is implemented on a composite key, the value of the composite key must be defined (to define the lower bound and the upper bound of the filter for example).
Several methods allow you to build the value of a composite key:Method 1: List of values:
All you have to do is specify the list of values that must be taken by each component of the composite key for the filter or for the search. The composite key is directly built in the syntax of the function.
Example: Find all the records in the CUSTOMER file whose last name is found between "AA" and "Barnaby" and whose first name is found between "Philomene" and "Tartuffe".
H过滤器（Customer， LastNameFirstName， 【"AA"， "Philomene"】， 【"Barnaby"， "Tartuffe"】）
In this example, "AA","Zorro" is returned by the filter while "Philomene","Zorro" is not returned.
Example: Find all the records in the Tasks file whose tasks are included between 15/03/2011 00:00 and 25/03/2011 00:00.
Method 2: Using the FOR EACH statement
H过滤器（Tasks， TaskStarDateTaskStartTime， 【20110315，0000】， 【20110325，0000】）
Specify the list of values that must be taken by each key component for the filter or for the search. The composite key is directly built in the syntax of the function.
Example: Finding the prospect customers living in state 69.
Method 3: Using H创建键值
The value of a composite key can be built by H创建键值. To do so, the relevant data file, the name of the key and the values of the components must be specified in this function.
For example, the following code line is used to build the value of the composite key ("NAMEDATE") corresponding to "CUSTOMERNAME+ORDER_DATE" of Customer file:
Method 4: Using HConvertX (method kept for backward compatibility with WinDev 5.5)
- entirely fill the text components with the h.最小值 constant.
- convert the numeric components with HConvert.