ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / Managing databases / HFSQL / HFSQL functions
  • Generic search/Exact-match search
  • Space characters at the end of item
  • Performing a search on a composite key
  • Search on an array item
  • Search and filter
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
HSeek (Function)
In french: HRecherche
ODBCNot available with this kind of connection
Positions on the first record of the data file whose value for a specific item is greater than or equal to a search value (generic search by default). The record is not read. To read the record, use HReadSeek.

The number of the current record is modified only when it is returned by HRecNum. For functions handling the current record number by default (functions HDelete, HRead, HModify, ...), the value of this number is not updated: you must use the HRecNum() function. For example: do not:
HDelete(Client)
but
HDelete(Client, HRecNum())
Read from smallest to largest browse item value (see notes for details).
Attention: Record loaded into memory is not modified. HFSQL variables (e. g. Customer.Name, or the Name item of the Customer data file) are not updated.
In most cases, HSeek sets the position in the data file to loop through the records that match a condition. HNext is used to position on the next record corresponding to the condition.
Several cases may occur after the call to HSeek:
  • a Record corresponding to the condition has been found: function HFound returns True
  • the data file is empty or there is no record corresponding to the condition: function HOut returns True
Remarks:
  • By default, HSeekFirst and HSeekLast are used to perform an exact-match search.
  • By default, HSeek performs a generic search.
Example
// Recherche générique du premier enregistrement pour lequel 
// le code postal commence par "75"
HSeek(Client, CP, "75")
// Recherche du premier enregistrement à l'identique
// pour lequel le nom du Client est Dupond
// Mode 7 : Rubrique texte terminée par Caract(0)
HSeek(Client, Nom, "Dupond" + Charact(0))

// Mode 5.5 : Rubrique texte complétée par des espaces
HSeek(Client, Nom, Complete("Dupond", 30))
Syntax
<Result> = HSeek(<Data file> , <Key item> , <Search value> [, <Options>])
<Result>: Boolean
  • True if the position was set,
  • False in the event of an error (blocking, etc.): the Record is not played. This problem can be caused by:
    • or a positioning problem (empty data file, etc.): function HFound returns False and function HError returns 0.
    • an error: HError returns an integer other than 0. HErrorInfo returns more details.
<Data file>: Character string
Name of the HFSQL data file used.
<Key item>: Character string
Name of key item on which the search will be performed.
<Search value>: Type corresponding to the value
Value of the sought item.
<Options>: Optional constant (or combination of constants)
Configures:
  • the lock mode applied to the sought record.
  • the type of iteration
  • the type of search performed.
hIdenticalExact-match search (see the Notes).
A generic search is performed by default (parameter not specified).
hKeepFilterThe filter set by HFilter will be taken into account, even if the search key is not optimized for the filter. Reminder: HFilter returns the optimized search key for the filter.
Warning: in this case, on large data files, performance problems may occur..
Hyper File 5.5 This variable cannot be used.
hLimitParsingThe iteration will stop when the last searched value is found. The current record will correspond to the record found. In this case, HFound returns False and HOut returns True.
This constant is used to optimize the speed in Client/Server mode.
hLockNoNo blocking: the Record can be played back or modified by another application during playback.
hLockReadWriteRead/write lock: the record being read cannot be read or modified by another application.
OLE DB Lock in write-only. Operating mode equivalent to the hLockWrite constant.
hLockWriteWrite lock: the record currently read can be read by another application but it cannot be modified by another application.
OLE DBNative Connectors (Native Accesses) The lock options will have no effect if the locks are not supported by the OLE DB provider or by the Native Connector.
Hyper File 5.5 The lock options are ignored. Use locking read functions (HReadFirstLock) kept for backward compatibility.
Remarks

Generic search/Exact-match search

A generic search or an exact-match search will be performed according to <Sought value>.
  • Generic search: searches for all records beginning with the specified value
    To perform a generic search, the desired value must be specified in <Sought value>.
  • Case of exact-match search In the case of an identical search: searches for all records corresponding exactly to the specified value.
    To perform an exact-match search, the size of the search argument must be exactly the same as the size of the key. The search argument must be filled with "space" characters for the text keys. To do so, use the Complete function.

Space characters at the end of item

By default, when a record is read, trailing spaces in text fields are not removed from variables associated with the data file.
In order for the space characters to be deleted, use WithSpace.

Performing a search on a composite key

Several methods can be used to perform a search on a composite key:
Using a list of values
The following syntax is used to perform a search on a composite key:
HSeek(<File name>, <Name of composite key>, ...
[<Search value of first element of composite key>,
<Search value of first element of composite key>, ...])
Example:
// Recherche de l'enregistrement
HSeek(Client, Nom_Prénom, ["MOULIN","Françoise"])
Hyper File 5.5 To perform generic searches on a composite key, all the components of composite key must be Text components. Otherwise, an exact-match search is performed.

Search on an array item

The search is performed on the first array element (element with index 1). To perform a search on the other array elements, use the filters or queries.

Search and filter

If a filter is enabled (HFilter), this filter is taken into account during the search.
Component: wd300hf.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 03/27/2025

Send a report | Local help