AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / WLanguage / Administrar bases de datos / HFSQL / Funciones HFSQL
  • When to use HBuildKeyValue?
  • Generic search
  • Building a composite key used in a filter with bounds
  • Building a composite key without using HBuildKeyValue
WINDEV
WindowsLinuxJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadIOS WidgetApple WatchMac Catalyst
Otros
Procedimientos almacenados
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(FileName, LINKEDCOMPKEY, ["Last name", "First name"])
Are equal to:
HReadSeekFirst(FileName, LINKEDCOMPKEY, ...
	HBuildKeyValue(FileName, LINKEDCOMPKEY, "Last name", "First name"))
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.
bufSoughtVal is Buffer

// Build the composite key
bufSoughtVal = HBuildKeyValue(Customer, LASTNAME_FIRSTNAME, "MOORE", "Vince")

// Build a String/Integer composite key
bufSoughtVal = HBuildKeyValue(Customer, LASTNAME_CUSTNUM, "MOORE", 12128)

// Build an Integer/Integer composite key
bufSoughtVal = HBuildKeyValue(Order, ORDERID_ORDERID, 12119,593)
Sintaxis
<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".
Observaciones

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(FileB, LINKEDCOMPKEY, HBuildKeyValue(FileA, COMPKEY, ...
		"Last name", "First name"))
or
bufKey is Buffer
bufKey = HBuildKeyValue(FileA, COMPKEY, "Last name", "First name")
HReadSeekFirst(FileB, LINKEDCOMPKEY, bufKey)
or
HReadSeekFirst(FileB, LINKEDCOMPKEY, FileA.COMPKEY)
if FileA is positioned on the record to search for in FileB.
You can also use an array of values instead of HBuildKeyValue:
HReadSeekFirst(FileB, LINKEDCOMPKEY, ["Last name", "First name"])

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(Customer, ...
    	HBuildKeyValue(Customer, LastNameFirstName, "Moore", "Vince") + hMinVal, ...
    	HBuildKeyValue(Customer, LastNameFirstName, "Moore", "Vince") + 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(Customer, LastNameFirstName, ...
    	HBuildKeyValue(Customer, LastNameFirstName, "Moore" + hMinVal), ...
    	HBuildKeyValue(Customer, LastNameFirstName, "Moore" + 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(FileB, LINKEDCOMPKEY, ["Last name", "First name"])
Componente: wd300hf.dll
Versión mínima requerida
  • Versión 9
Esta página también está disponible para…
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 28/03/2025

Señalar un error o enviar una sugerencia | Ayuda local