- 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
In french: HRecherche
Not 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 sought value (generic search by default). The record is not read
. To read the record, use HReadSeek
The number of the current record is only changed when it is returned by the HRecNum
function. For functions that manipulate by default the number of the current record (functions HDelete
,...), the value of this number is not updated: you must use HRecNum
(). For example: not to do:
LThe reading is from the smallest to the largest value of the route field (see notes for more details).
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, HSeek
is used to position in the data file in order to perform a browse loop among the records corresponding to 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 was found: HFound returns True
- the data file is empty or there is no record corresponding to the condition: HOut returns True
- By default, HSeekFirst and HSeekLast are used to perform an exact-match search.
- By default, HSeek is used to perform a generic search.
// Generic search for the first record for which
// the zip code starts with "75"
HSeek(CUSTOMER, ZC, "75")
// Exact-match search for the first record
// for which the CUSTOMER name is MOORE
// Mode 7: Text item ending with Charact(0)
HSeek(CUSTOMER, NAME, "MOORE" + Charact(0))
// Mode 5.5: Text item filled by space characters
HSeek(CUSTOMER, NAME, Complete("MOORE", 30))
<Result> = HSeek(<Data file> , <Key item> , <Sought value> [, <Options>])
- True if the positioning was performed,
- False if an error occurred (lock, ...): the record is not read. This problem can be caused by:
- a positioning problem (empty data file, ...): HFound returns False and HError returns 0.
- an error: HError returns an integer other than 0. HErrorInfo returns more details.
<Data file>: Character string (with or without quotes)
Name of HFSQL data file used.
<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)
- the lock mode applied to the sought record. By default, the lock performed corresponds to the current lock mode, defined by HStartLock.
- the type of browse
- the type of search performed.
|hLockReadWrite||Lock in read/write: the record currently read cannot be read or modified by another application.|
Lock in write-only. Operating mode equivalent to the hLockWrite
|hLockWrite||Lock in write mode: the record currently read can be read by another application but it cannot be modified by another application.|
|hLockNo||No lock (even if HStartLock was called): the record can be read or modified by another application during the reading.|
|hIdentical||Exact-match search (see the Notes). |
A generic search is performed by default (parameter not specified).
|hLimitParsing||The browse will stop as soon as the last sought 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.
|hKeepFilter||The 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, poor performance may occur on huge data files.
This variable cannot be used.
Access by JDBC: This parameter is ignored.
The lock options will have no effect if the locks are not supported by the OLE DB provider or by the Native Access.
The lock options are ignored. Use the locking read functions (HReadFirstLock
) kept for backward compatibility.
Generic search/Exact-match search
A generic search or an exact-match search will be performed according to <Sought Value>.
- For a generic search: performs a search on all the records that starts by the specified value
To perform a generic search, the requested value must be specified in <Sought value>.
- For an exact-match search: performs a search of all the records that exactly match 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 Complete.
Space characters at the end of item
By default, when reading a record, the space characters found at the end of the text items are not deleted in the file variables.
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>, ...])
// Find the record
HSeek(CUSTOMER, LASTNAME_FIRSTNAME, ["MOORE","Vince"])
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.
This page is also available for…