|
|
|
|
|
- Generic search/Exact-match search
- Performing a search on a composite key
- Search on an array item
- Search and filter
- Locks
HSeekFirst (Function) In french: HRecherchePremier
Not available with this kind of connection
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 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: use function HRecNum. Example not to do:
HSeekFirst(Customer, CustomerID, 25)
HDelete(Customer)
but:
HSeekFirst(Customer, CustomerID, 25)
HDelete(Customer, HRecNum())
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, HSeekFirst sets the position in the data file to loop through the records that match a condition. Several cases may occur after the call to HSeekFirst: - 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.
HSeekFirst(Customer, Name, "Moore")
bufSoughtVal is Buffer = HBuildKeyValue(Customer, LastName_FirstName, sLastName, sFirstName)
HSeekFirst(Customer, LastName_FirstName, bufSoughtVal, hLockWrite)
WHILE HFound(Customer) = True
HDelete(Customer, HRecNum())
HNext(Customer, LastName_FirstName, hLockWrite)
END
Syntax
<Result> = HSeekFirst(<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.
| | hGeneric | Generic search (see the Notes) An exact-match search is performed by default (constant not specified). | hKeepFilter | The 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 files, performance problems may arise.. By default, the iteration performed after HSeekFirst ignores the filter. | hLimitParsing | The iteration will stop when the last searched 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. | hLockNo | No blocking: the recording can be played back or modified by another application during playback. | hLockReadWrite | Read/write lock: the record being read cannot be read or modified by another application.
| hLockWrite | Write lock: the record currently read can be read by another application but it cannot be modified by another application. |
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 string "Martin" for the field NAME, the function HFound returns True only for records where the field is exactly "Martin". - Examples of searches performed on CUSTOMER file sorted by name:
| | | | | | Search value | Options | HSeekFirst sets the position on the record | HFound returns | HOut returns | Explanations | Durand | | 1 | True | False | Durand exists. The end of data file was not reached yet. | Dupuis | | 1 | False | False | Dupuis does not exist. Positioning on the first greater value (Durand). The end of data file was not reached yet. | Moor | hGeneric | 8 | True | False | Moor does not exist but the search is a generic search and Moore is found (among others). The end of data file was not reached yet. | Moor | | The record was not found (no move) | False | False | Moor does not exist. The end of data file was not reached yet. | Norbert | | The record was not found (no move) | False | True | Norbert does not exist. Position on first upper value (this value does not exist): The end of the data file is reached. |
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.
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|