- 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
<Source>.Seek (Function) In french: <Source>.Recherche
Not available with this kind of connection
The number of the current record is modified when it is returned by <Source>.RecNum. For the functions that handle the current record number ( <Source>.Delete, <Source>.Read, <Source>.Modify, ...), the value of this number is not updated: you must use <Source>.RecNum(). For example: not to do:
but
Customer.Delete(Customer.RecNum())
The reading is performed from the lowest to the greatest value of the browse item (see the remarks 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, <Source>.Seek sets the position in the data file to browse through the records that correspond to a condition. <Source>.Next is used to position on the next record corresponding to the condition. Several cases may occur after the call to <Source>.Seek: - a record corresponding to the condition was found: <Source>.Found returns True
- the data file is empty or there is no record corresponding to the condition: <Source>.Out returns True
Remarks: Versions 15 and later New in version 15 Versions 17 and later New in version 17 Versions 18 and later New in version 18 Remark: From version 19, HFSQL is the new name of HyperFileSQL. Versions 21 and later New in version 21
// Generic search for the first record for which // the zip code starts with "75" Customer.Seek(ZC, "75")
// Exact-match search for the first record // for which the Customer name is Moore // Mode 7: Text item ending with Charact(0) Customer.Seek(Name, "Moore" + Charact(0)) // Mode 5.5: Text item filled by space characters Customer.Seek(Name, Complete("Moore", 30))
Syntax
<Result> = <Source>.Search(<Key item> , <Sought value> [, <Options>])
<Result>: Boolean - True if the position was set,
- False if an error occurred (lock, ...): the record is not read. This problem can be caused by:
<Source>: Type corresponding to the specified source 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) Configures:- 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.
| 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, <Source>.Found returns False and <Source>.Out returns True. This constant is used to optimize the speed in Client/Server mode. | hKeepFilter | The filter implemented 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 issues may arise for large files.
|
Remarks 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 valuesThe 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>, ...])
Example:
// Find the record Customer.Seek(LastName_FirstName, ["MOORE","Vince"])
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 ( <Source>.Filter), this filter is taken into account during the search.
This page is also available for…
|
|
|