PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK

  • Generic search/Exact-match search
  • Performing a search on a composite key
  • Search on an array item
  • Search and filter
  • Locks
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Positions on the first file record whose value for a specific item is greater than or equal to a sought value. The record is not read.
The number of the current record is modified when it is returned by HRecNum. For the functions that handle the current record number (HDelete, HRead, HModify, ...), the value of this number is not updated: you must use HRecNum.
Example not to do:
// Deletes a record not corresponding to the expected one
HSeekFirst(Customer, CustomerID, 25)
HDelete(Customer)
to do:
// Delete the sought record
HSeekFirst(Customer, CustomerID, 25)
HDelete(Customer, HRecNum())
Caution: The record loaded in memory is not modified. The HFSQL variables (Customer.Name for example, which means the Name item of Customer file) are not updated.
In most cases, HSeekFirst is used to position in the data file in order to perform a browse loop among the records corresponding to a condition.
Several cases may occur after the call to HSeekFirst:
  • a record corresponding to the condition was found, locked (if necessary) and loaded in memory: HFound returns True.
  • the data file is empty or there is no record corresponding to the condition: HOut returns True.
  • the function tries to lock a record that is already locked in read-only: HErrorLock returns True and HOut returns True.
Note: the search can be canceled by HCancelSeek.
Remark: From version 19, HFSQL is the new name of HyperFileSQL.
Example
// Find the first record for which
// the CUSTOMER name is MOORE
HSeekFirst(CUSTOMER, NAME, "MOORE")
// The record is not read.
// Finds all the customers with a specific last and first names.
// The search is performed according to a composite key.
bufSoughtVal is Buffer = HBuildKeyValue(CUSTOMER, LASTNAME_FIRSTNAME, sLastName, sFirstName)
HReadSeek(CUSTOMER, LASTNAME_FIRSTNAME, bufSoughtVal, hLockWrite)
WHILE HFound(CUSTOMER) = True
HDelete(CUSTOMER, HRecNum())
HNext(CUSTOMER, LASTNAME_FIRSTNAME, hLockWrite)
END
Syntax
<Result> = HSeekFirst(<File name> , <Name of key item> , <Sought value> [, <Options>])
<Result>: Boolean
  • True if the positioning was performed (corresponds to the value of HFound).
  • False if a problem occurred. This problem can be caused by:
    • a positioning problem (empty data file, etc.): HFound returns False and HError returns 0.
    • an error: HError returns an integer other than 0. HErrorInfo returns more details.
<File name>: Character string (with or without quotes)
Name of HFSQL data file used.
<Name of key item>: Character string (with or without quotes)
Name of key item on which the search will be performed.
<Sought value>: Type corresponding to the value
Value of sought item.
<Options>: Optional constant (or combination of constants)
Configures:
  • the lock mode applied to the sought record
  • the type of search performed.
hLockReadWriteLock in read/write: the record currently read 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 currently read can be read by another application but it cannot be modified by another application.
hLockNoNo lock (even if HStartLock was called): the record can be read or modified by another application during the reading.
hGenericGeneric search (see the Notes)
An exact-match search is performed by default (constant not specified).
hLimitParsingThe browse will stop as soon as the last sought value is found. The current record will correspond to this last record found.
HFound will return False and HOut will return True.
This constant is used to optimize the search speed in Client/Server mode.
hKeepFilterThe filter implemented by HFilter will be taken into account, even if the search key is not optimized for the filter. Reminder: HFilter returns the search key optimized for the filter.
Caution: in this case, lack of performance may occur on the huge files.
Hyper File 5.5 This variable cannot be used.
By default, the browse operation performed after HSeekFirst ignores the filter.
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 Access.
OLE DB The lock mode specified by HSeekFirst will remain effective during the calls to HPrevious and HNext.
To modify the lock mode, you must use:
Remarks

Generic search/Exact-match search

  • Generic search (mainly on the Character String items): Finds all the records starting with the specified value.
    For example: When a generic search is performed on "Martin" (for the NAME item), all records whose Name item starts with "Martin" will correspond to the search. Therefore, the record containing "Martinez" will correspond to the search (HFound returns True).
  • Exact-match search: Finds all the records that exactly correspond to the specified value.
    For example: When an exact-match search is performed on "Smith" (for the NAME item), HFound returns True for the records whose item exactly matches "Smith".
  • Examples of searches performed on CUSTOMER file sorted by name:
Sought valueOptionsHSeekFirst positions on the recordHFound returnsHOut returnsExplanations
Durand1TrueFalseDurand exists.
The end of data file was not reached yet.
Dupuis1FalseFalseDupuis does not exist. Positioning on the first greater value (Durand).
The end of data file was not reached yet.
DuponhGeneric8TrueFalseDupon does not exist but the search is a generic search and Dupond is found (among other ones).
The end of data file was not reached yet.
DuponThe record was not found (no move)FalseFalseDupon does not exist.
The end of data file was not reached yet.
NorbertThe record was not found (no move)FalseTrueNorbert does not exist.
Position on the first greater value (this value does not exist): The end of data file has been reached.
Reports and QueriesHFSQLHFSQL 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:
Using a list of values
The following syntax is used to perform a search on a composite key:
HSeekFirst(<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
HSeekFirst(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 whose subscript is 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.
Hyper File 5.5 If a filter is enabled, the filter is ignored by the search.
Reports and QueriesHFSQLHFSQL 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.
There is no need to specify a lock parameter if the data file is locked by HStartLock: the lock specified by HStartLock is automatically taken into account. To ignore the lock specified by HStartLock, use the hLockNo constant.
Reminder: A locked record can be unlocked by 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 Access.
Component : wd250hf.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment