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
  • Performing a search on a composite key
  • Search on an array item
  • Search and filter
  • Locks
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Sets the position on the last data file record whose value for a specific item is less than or equal to a sought value. The record is not read.
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(Customer)
but
HDelete(Customer, HRecNum())

Reading is done from the smallest to the largest value of the browse item (see notes for details).
Warning: Recording loaded into memory is not modified. The HFSQL variables (for example Customer.Name, i.e. the Name item of the Customer file) are not updated.
In most cases, HSeekLast sets the position in the data file to loop through the records that match a condition.
Several cases may occur after the call to HSeekLast:
  • 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: function HOut returns True.
  • the function attempts to block a record already blocked in playback: function HErrorLock returns True and function HOut returns True.
Note: the search can be cancelled by pressing HCancelSeek.
Example
// Find the last record for which the Customer name is Moore
HSeekLast(Customer, Name, "Moore")
// This example is used to find all the customers 
// whose turnover is less than a specific value. 
HSeekLast(Customer, Turnover, X)
WHILE NOT HOut(Customer)
	AddCustomerList()
	HPrevious(Customer, Turnover)
END
Syntax
<Result> = HSeekLast(<Data file> , <Key item> , <Search value> [, <Options>])
<Result>: Boolean
  • True if the position was set on the record (corresponds to the value of HFound).
  • False if a problem occurs. This problem can be caused by:
    • or a positioning problem (empty data file, etc.): function HFound returns Faux 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 search performed.
hGenericGeneric search (see the Notes)
An exact-match 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.
By default, the iteration performed after HSeekLast ignores the filter.
hLimitParsingThe 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.
hLockNoNo blocking: the recording can be played back or modified by another application during playback.
hLockReadWriteLock in read/write mode: record cannot be read or modified by another application.
OLE DB Lock in write-only. Operating mode equivalent to the hLockWrite constant.
hLockWriteLock in write mode: the record can be read by another application, but cannot be modified by another application.
Java Access through JDBC: This parameter is ignored.
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.
OLE DB The lock mode specified by HSeekLast will remain effective during the calls to HPrevious and HNext.
To change the lock mode, use:
Remarks

Generic search/Exact-match search

  • Generic search (mainly for string fields): Finds all records beginning with the specified value.
    For example: When performing a generic search for the string "Martin" in the NAME field, all records whose Name field begins with "Martin" will match the search. Therefore, the record containing "Smither" will correspond to the search (HFound returns True).
  • Exact-match search: Finds all records exactly matching the specified value.
    For example: When performing an exact-match search on the "Matin" channel for the NAME item, the function HFound returns True only for records where the field is exactly "Martin".
  • Examples or searches performed on CUSTOMER file sorted by name:
Search valueOptionsHSeekLast sets the position on the recordHFound returnsHOut returnsExplanations
Durand6TrueFalseDurand exists.
The beginning of data file was not reached yet.
Dupuis5FalseFalseDupuis does not exist. Positioning on the first lower value (Moore).
The beginning of data file was not reached yet.
MoorhGeneric5TrueFalseMoor does not exist but the search is generic, and Moore is found (among others).
The beginning of data file was not reached yet.
MoorThe record was not found (no move)FalseFalseMoor does not exist.
The beginning of data file was not reached yet.
BernardThe record was not found (no move)FalseTrueBernard does not exist.
Position on first lower value (this value does not exist): The start of the data file is reached.

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:
HSeekLast(<File name>, <Name of composite key>, ...
[<Search value of first element of composite key>,
<Search value of first element of composite key>, ...])
Example:
// Find the record
HSeekLast(Customer, LastName_FirstName, ["Moore", "Vince"])
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), the search takes the filter into account.
Hyper File 5.5 If a filter is enabled, the filter is ignored by the search.
WINDEVWEBDEV - Server codeReports and QueriesiPhone/iPadJavaUser code (UMC)External languageAjaxHFSQL ClassicHFSQL Client/ServerHyper File 5.5OLE DBNative Connectors (Native Accesses)

Locks

The locks apply only when a record was found.
By default (no lock mode specified in <Options>), the record is not locked.
If a lock is requested (hLockWrite or hLockReadWrite constant), the record will be read only if this record is not already locked.
Reminder: A blocked recording can be unlocked by pressing HUnlockRecNum.
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.
Component: wd300hf.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 12/07/2024

Send a report | Local help