ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / Managing databases / HFSQL / HFSQL functions
  • When to use <Source>.BuildKeyValue?
  • Generic search
  • Building a composite key used in a filter with bounds
  • Building a composite key without using <Source>.BuildKeyValue
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
<Source>.BuildKeyValue (Function)
In french: <Source>.ConstruitValClé
ODBCNot available with this kind of connection
Builds the value of a composite key to implement a filter (<Source>.Filter) or to perform a search (<Source>.ReadSeekFirst, <Source>.ReadSeekLast, etc.).
This function can be replaced with an array of values, easier to use. For example:
NomFichier.LitRecherchePremier(CLECOMPREL, ["Le nom", "Le prénom"])
Are equal to:
NomFichier.LitRecherchePremier(CLECOMPREL, ...
	NomFichier.ConstruitValClé(CLECOMPREL, "Le nom", "Le prénom"))
Tip To browse a data file using a compound key, use FOR EACH on compound key (syntax 5).
For more details on composite keys in WINDEV, see Composite keys.
Reminder Compound keys are binary strings whose contents cannot be displayed directly.
Example
bufValRech is Buffer

// Construction de la clé composée
bufValRech = Client.ConstruitValClé(NOM_PRENOM, "MOULIN", "Françoise")

// Construction d'une clé composée Chaîne/Entier
bufValRech  = Client.ConstruitValClé(NOM_NUMCLI, "MOULIN", 12128)

// Construction d'une clé composée Entier/Entier
bufValRech  = Commande.ConstruitValClé(IDCOMMANDE_IDCOMMANDE, 12119,593)
Syntax
<Result> = <Source>.BuildKeyValue(<Composite key> , <Value of components>)
<Result>: Buffer
Value of the composite key.
<Source>: Type corresponding to the specified source
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 <Source>.BuildKeyValue?

<Source>.BuildKeyValue 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:
FichierB.LitRecherchePremier(CLECOMPREL, FichierA.ConstruitValClé(CLECOMP, ...
		"Le nom", "Le prénom"))
or
bufCle is Buffer
bufCle = FichierA.ConstruitValClé(CLECOMP, "Le nom", "Le prénom")
FichierB.LitRecherchePremier(CLECOMPREL, bufCle)
or
FichierB.LitRecherchePremier(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 <Source>.BuildKeyValue:
FichierB.LitRecherchePremier(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 <Source>.BuildKeyValue.
  • 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":
    Client.Filtre(...
    	Client.ConstruitValClé(NomPrénom, "Moulin", "Françoise") + hMinVal, ...
    	Client.ConstruitValClé(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":
    Client.Filtre(NomPrénom, ...
    	Client.ConstruitValClé(NomPrénom, "Moulin" + hMinVal), ...
    	Client.ConstruitValClé(NomPrénom, "Moulin" + hMaxVal))
Remarks:
  • hMinVal is equivalent to Charact(0)
  • hMaxVal is equivalent to Charact(255)

Building a composite key without using <Source>.BuildKeyValue

You can use an array of values to build the value of a composite key without using <Source>.BuildKeyValue.
For example:
FichierB.LitRecherchePremier(CLECOMPREL, ["Le nom", "Le prénom"])
Component: wd300hf.dll
Minimum version required
  • Version 25
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 12/04/2024

Send a report | Local help