|
|
|
|
|
- When to use HBuildKeyValue?
- Generic search
- Building a composite key used in a filter with bounds
- Building a composite key without using HBuildKeyValue
HBuildKeyValue (Function) In french: HConstruitValClé
Not available with this kind of connection
Builds the value of a composite key to implement a filter ( HFilter) or to perform a search ( HReadSeekFirst, HReadSeekLast, etc.). This function can be replaced with an array of values, easier to use. For example:
HReadSeekFirst(NomFichier, CLECOMPREL, ["Le nom", "Le prénom"])
Are equal to:
HReadSeekFirst(NomFichier, CLECOMPREL, ...
HBuildKeyValue(NomFichier, CLECOMPREL, "Le nom", "Le prénom"))
Tip To browse a data file using a compound key, use FOR EACH on compound key (syntax 5). Reminder Compound keys are binary strings whose contents cannot be displayed directly.
bufValRech is Buffer
bufValRech = HBuildKeyValue(Client, NOM_PRENOM, "MOULIN", "Françoise")
bufValRech = HBuildKeyValue(Client, NOM_NUMCLI, "MOULIN", 12128)
bufValRech = HBuildKeyValue(Commande, IDCOMMANDE_IDCOMMANDE, 12119,593)
Syntax
<Result> = HBuildKeyValue(<Data file> , <Composite key> , <Value of components>)
<Result>: Buffer Value of the composite key. <Data file>: Character string Name of the HFSQL data file used. <Composite key>: Character string Name of the item corresponding to the composite key <Value of components>: Character string Value that will be assigned to each component of the composite key. This parameter has the following format:
<Component 1>, <Component 2>, ..., <Component N> For example: "MOULIN", "Françoise". Remarks When to use HBuildKeyValue? HBuildKeyValue can be used to perform searches on binary string keys linked to composite keys. For example: - FileA file:
COMPKEY is a composite key of FileA. Composition: FileA.Last name+FileA.First name - FileB file:
LINKEDCOMPKEY is a binary string key linked to FileA.COMPKEY
Performing a search on the value of the composite key:
HReadSeekFirst(FichierB, CLECOMPREL, HBuildKeyValue(FichierA, CLECOMP, ...
"Le nom", "Le prénom"))
or
bufCle is Buffer
bufCle = HBuildKeyValue(FichierA, CLECOMP, "Le nom", "Le prénom")
HReadSeekFirst(FichierB, CLECOMPREL, bufCle)
or
HReadSeekFirst(FichierB, CLECOMPREL, FichierA.CLECOMP)
if FileA is positioned on the record to search for in FileB. You can also use an array of values instead of HBuildKeyValue:
HReadSeekFirst(FichierB, CLECOMPREL, ["Le nom", "Le prénom"])
Generic search When a generic search is performed, there is no need to define the values of all the components. Only the first n values are required (n being included between 1 and the number of key components, including bounds). Building a composite key used in a filter with bounds To build the value of a composite key used in a filter, call HBuildKeyValue. - If the lower bound and the upper bound of the filter must be identical, the hMinVal and hMaxVal constants must be used to fill the bounds.
The following example is used to find all the records of Customer file corresponding to "Vince Moore":
HFilter(Client, ...
HBuildKeyValue(Client, NomPrénom, "Moulin", "Françoise") + hMinVal, ...
HBuildKeyValue(Client, NomPrénom, "Moulin", "Françoise") + hMaxVal)
- If the lower bound and the upper bound must be identical and if some key components are not specified, the hMinVal and hMaxVal constants must be used to fill the bounds.
The following example is used to find all the records of Customer file corresponding to "Moore":
HFilter(Client, NomPrénom, ...
HBuildKeyValue(Client, NomPrénom, "Moulin" + hMinVal), ...
HBuildKeyValue(Client, NomPrénom, "Moulin" + hMaxVal))
Remarks: - hMinVal is equivalent to Charact(0)
- hMaxVal is equivalent to Charact(255)
Building a composite key without using HBuildKeyValue You can use an array of values to build the value of a composite key without using HBuildKeyValue. For example: HReadSeekFirst(FichierB, CLECOMPREL, ["Le nom", "Le prénom"])
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|