PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN

  • 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
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
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 according to a composite key, use the FOR EACH statement on composite key (syntax 5).
For more details on compound key management in WINDEV, see Composite keys.
Reminder: The composite keys are binary strings whose content cannot be displayed directly.
Versions 15 and later
Android This function is now available for Android applications.
New in version 15
Android This function is now available for Android applications.
Android This function is now available for Android applications.
Versions 17 and later
iPhone/iPad This function is now available for iPhone/iPad applications.
New in version 17
iPhone/iPad This function is now available for iPhone/iPad applications.
iPhone/iPad This function is now available for iPhone/iPad applications.
Versions 18 and later
Android Widget This function is now available in Android widget mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
New in version 18
Android Widget This function is now available in Android widget mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
Android Widget This function is now available in Android widget mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
Versions 21 and later
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
New in version 21
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Remark: From version 19, HFSQL is the new name of HyperFileSQL.
Example
bufValRech est un 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 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:
<Composante 1>, <Composante 2>, ..., <Composante N>
For example: "MOORE", "Vince".
Remarks

When to use <Source>.BuildKeyValue?

The <Source>.BuildKeyValue function can and should be used to search for keys that are linked (binary string type) to compound keys.
For example:
  • FileA file:
    COMPKEY is a composite key of FileA. Composition: FileA.LastName+FileA.FirstName
  • 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 est un 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 that must be found in FILEB.
It is also possible to use an array of values instead of the <Source>.BuildKeyValue function:
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 construct the value of a compound key used in a filter, use function <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") + hValMin, ...
    Client.ConstruitValClé(NomPrénom, "Moulin", "Françoise") + hValMax)
  • 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" + hValMin), ...
    Client.ConstruitValClé(NomPrénom, "Moulin" + hValMax))
Remarks:
  • hMinVal is equivalent to Charact(0)
  • hMaxVal is equivalent to Charact(255)

Building a composite key without using <Source>.BuildKeyValue

To construct the value of a compound key without using the <Source>.BuildKeyValuefunction, two solutions are possible:
  • Solution 1: Using an array of values (recommended solution):
    For example:
    FichierB.LitRecherchePremier(CLECOMPREL, ["Le nom", "Le prénom"])
  • Solution 2: Managing each type of component:
    • entirely fill the text components with the hMinVal constant.
    • convert the numeric components with HConvert.
    For example:
    MaClécomposée = Complète(Client.NomClient, ...
    Dimension(Client.Nom), hMinVal) + ...
    Complète(Client.Prénom, Dimension(Client.Prénom), hMinVal)
Remark: It is recommended to use <Source>.BuildKeyValue. The hMinVal constant is equivalent to Charact(0).
Component: wd270hf.dll
Minimum version required
  • Version 25
This page is also available for…
Comments
Click [Add] to post a comment