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
  • Exact-match search in Access
  • Performing a search on a composite key
  • Search on an array item
  • Search and filter
  • Looping through records that match a condition
  • Optimizing iterations
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Positions on the first file record whose value for a specific item is greater than or equal to a sought value (generic search). The record is read and the corresponding HFSQL variables are updated.
In most cases, HReadSeek sets the position in the data file to loop through the records that match a condition. HReadNext is used to read the next record corresponding to the condition.Several cases may occur after the call to HReadSeek:
  • a record corresponding to the condition has been found, blocked (if necessary) and loaded into memory: function HFound returns True.
  • the data file is empty or there is no record corresponding to the condition: no read is performed and function HOut returns True.
This function can be used with the data files, HFSQL views or queries.
Remarks:
  • By default, HReadSeekFirst and HReadSeekLast are used to perform exact-match searches.
  • By default, HReadSeek is used to perform a generic search on strings. This search is not generic on integers, reals, dates, currencies, etc.
// Recherche du premier enregistrement 
// pour lequel le nom du CLIENT est DUPOND
HReadSeek(CLIENT, NOM, "DUPOND")
IF HFound() THEN
	Trace("Client DUPOND trouvé")
ELSE
	Trace("Client DUPOND non trouvé")
END
Syntax
<Result> = HReadSeek(<Data file> , <Item> , <Search value> [, <Options>])
<Result>: Boolean (optional)
Corresponds to:
  • True if the sought record was found and read. The file buffer is loaded with the data of the record found. In this case, HError is set to 0 and HFound is set to True.
  • False in the following cases:
    • error while accessing the file (unable to read for example). HError returns an error code. HErrorInfo returns more details about the error. In this case, HFound cannot be used.
    • the access to the file was performed but no record was found. In this case, HError is set to 0 and HFound is set to False.
    Warning: In this case, the file buffer cannot be used..
<Data file>: Character string
Name of data file, HFSQL view or query used.
<Item>: Character string
Name of item on which the search will be performed.
For an exact-match search, this parameter can correspond to a non-key item.
Hyper File 5.5 To perform generic searches on a composite key, all the components of the composite key must be text components. Otherwise, an exact-match search is performed.
<Search value>: Type corresponding to the value
Value of the sought item.
<Options>: Optional constant (or combination of constants)
Used to configure:
  • the lock mode applied to the sought record.
  • the type of search performed.
hIdenticalExact-match search (see the Notes)
A generic search is performed by default (constant 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.
Caution: in this case, on large data files, performance problems may occur..
Hyper File 5.5 This variable cannot be used.
hLimitParsing
ODBCNative Connectors (Native Accesses) The iteration will stop when the last searched value is found. The current record will correspond to this last record found.
HFound will be set to False and HOut will be set to True.
This constant is used to optimize the search speed in Client/Server mode.
This constant is recommended when performing a simple search (without looping through the found elements).
HFSQL Client/Server This constant is not available.
hLockNoNo blocking: the recording 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.
The lock mode is ignored if a query is used.
ODBC 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.
The lock mode is ignored if a query is used.
hNoRefresh
ODBCNative Connectors (Native Accesses) HReadSeek does not refresh the content of the table or query. If possible, the query is not re-run. All the saved positions are stored.
ODBCNative 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.
Remarks
Reports and QueriesHFSQL ClassicHFSQL Client/ServerHyper File 5.5OLE DBNative Connectors (Native Accesses)

Generic search/Exact-match search

A generic search or an exact-match search will be performed according to <Sought value>.
  • Generic search: search for all records beginning with the specified value
    To perform a generic search, the desired value must be specified in <Sought value>.
    Note: For compatibility with WINDEV 5.5, the generic search for an empty string ("") is equivalent to using the HReadFirst function..
  • Identical search: search for all records exactly matching 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. To perform an exact-match search, you also have the ability to use the hIdentical constant.
    To perform an exact-match search, you also have the ability to use HReadSeekFirst.
Caution: If you're using Hyper File 5.5 files or files in Hyper File 5.5 format migrated to HFSQL Classic, the implementation of generic and exact-match searches may vary.. For more details, see the Hyper File 5.5 and HFSQL Classic: How are spaces handled in searches? table
Reports and QueriesNative Connectors (Native Accesses)

Exact-match search in Access

To perform an exact-match search on an ACCESS database, it is recommended to use NoSpace if there are space characters at the end of the sought value.
Reports and QueriesHFSQL ClassicHFSQL Client/ServerHyper File 5.5OLE DBNative Connectors (Native Accesses)

Performing a search on a composite key

Several methods can be used to perform a search on a composite key:
1. Using a list of values
The following syntax is used to perform a search on a composite key:
HLitRecherche(<Nom du fichier>, <Nom de la clé composée>,
[<Valeur de recherche du premier élément de la clé composée>,
<Valeur de recherche du deuxième élément de la clé>, ...])
Example:
// Recherche de l'enregistrement
HReadSeek(CLIENT, NOM_PRENOM, ["MOULIN","Françoise"])

WHILE HFound(CLIENT)
	// Traitement
	HReadNext(CLIENT, NOM_PRENOM)
END

2. Using HBuildKeyValue
If the sought item is a composite key, the value to find can be built by HBuildKeyValue.
Hyper File 5.5 To perform generic searches on a composite key, all the components of the composite key must be text components. Otherwise, an exact-match search is performed.
Reports and QueriesHFSQL ClassicHFSQL Client/ServerHyper File 5.5OLE DBNative Connectors (Native Accesses)

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.
Reports and QueriesHFSQL ClassicHFSQL Client/ServerHyper File 5.5OLE DBNative Connectors (Native Accesses)

Search and filter

If a filter is enabled (HFilter), the filter is taken into account by the search only if the key used is identical.
Reports and QueriesHFSQL ClassicHFSQL Client/ServerHyper File 5.5OLE DBNative Connectors (Native Accesses)

Looping through records that match a condition

In most cases, HReadSeek sets the position in the data file to loop through the records that match a condition. HReadNext and HReadPrevious are used to read the next and previous matching records.
To ignore the search while going to the next or previous record, use one of the following functions:
Reports and QueriesHFSQL ClassicHFSQL Client/ServerHyper File 5.5OLE DBNative Connectors (Native Accesses)

Optimizing iterations

To optimize the first iterations on a data file, use HOptimize on this data file.
Component: wd300hf.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 09/24/2024

Send a report | Local help