|
|
|
|
|
- Generic search/Exact-match search
- Performing a search on a composite key
- Search on an array item
- Search and filter
- Locks
<Source>.SeekFirst (Function) In french: <Source>.RecherchePremier
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 <Source>.RecNum. For the functions that handle the current record number ( <Source>.Delete, <Source>.Read, <Source>.Modify, etc.), the value of this number is not updated: you must use <Source>.RecNum. Example not to do:
Client.RecherchePremier(IDClient, 25)
Client.Supprime()
but:
Client.RecherchePremier(IDClient, 25)
Client.Supprime(Client.NumEnr())
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, <Source>.SeekFirst sets the position in the data file to loop through the records that match a condition. Several cases may occur after the call to <Source>.SeekFirst: - a record corresponding to the condition was found, locked (if necessary) and loaded in memory: <Source>.Found returns True.
- the data file is empty or there is no record corresponding to the condition: <Source>.Out returns True.
- the function tries to lock a record that is already locked in read-only: HErrorLock returns True and <Source>.Out returns True.
Client.RecherchePremier(Nom, "Dupond")
bufValRech is Buffer = Client.ConstruitValClé(Nom_Prénom, sNom, sPrénom)
Client.RecherchePremier(Nom_Prénom, bufValRech, hLockWrite)
WHILE Client.Trouve() = True
Client.Supprime(Client.NumEnr())
Client.Suivant(Nom_Prénom, hLockWrite)
END
Syntax
<Result> = <Source>.SeekFirst(<Key item> , <Sought value> [, <Options>])
<Result>: Boolean - True if the position was set on the record (corresponds to the value of <Source>.Found).
- False if a problem occurs. This problem can be caused by:
<Source>: Type corresponding to the specified source Name of the HFSQL data file used. <Key item>: Character string Name of key item on which the search will be performed. <Sought 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 <Source>.Filter will be taken into account, even if the search key is not optimized for the filter. Reminder: <Source>.Filter returns the search key optimized for the filter. Caution: in this case, performance problems may occur on large files. By default, the iteration performed after <Source>.SeekFirst 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. <Source>.Found will return False and <Source>.Out will return True. This constant is used to optimize the search speed in Client/Server mode. | hLockNo | No lock: the record can be read or modified by another application during the reading. | hLockReadWrite | Lock in read/write mode: the record currently read cannot be read or modified by another application.
| hLockWrite | Lock in write mode: 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 on the Character String items): Finds all the records starting with the specified value.
For example: When a generic search is performed on "Smith" (for the NAME item), all records whose Name item starts with "Smith" will match the search. Therefore, the record containing "Smither" 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:
| | | | | | Search value | Options | <Source>.SeekFirst sets the position on the record | <Source>.Found returns | <Source>.Out 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 the first greater value (this value does not exist): The end of data file has been 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 ( <Source>.Filter), the search takes the filter into account.
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|