- Generic search/Exact-match search
- Exact-match search in Access
- Performing a search on a composite key
- Search on an array item
- Search and filter
- Browsing the records corresponding to a condition
- The views and RPC on HFSQL
- Optimizing the browse operations
HReadSeek (Function) In french: HLitRecherche
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 (generic search). The record is read and the corresponding HFSQL variables are updated. In most cases, HReadSeek is used to position in the data file in order to perform a browse loop among the records corresponding to a condition. HReadNext is used to read the next record corresponding to the condition.Several cases may occur after the call to HReadSeek: - a record corresponding to the condition was found, locked (if necessary) and loaded in memory: HFound returns True.
Access by JDBC: The management of locks is not available for the databases accessed by JDBC. - the data file is empty or there is no record corresponding to the condition: no reading is performed and HOut returns True.
This function can be used with the data files, HFSQL views or queries. Remarks: - By default, HReadSeekFirst and HReadSeekLast are used to perform exact-match searches.
- By default, HReadSeek is used to perform a generic search on the character strings. This search is not a generic search on the integers, the reals, the dates, the currencies, ...
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
// Find the first record // for which the CUSTOMER name is MOORE HReadSeek(CUSTOMER, NAME, "MOORE") IF HFound() THEN Trace("Customer MOORE found") ELSE Trace("Customer MOORE not found") END
Syntax
<Result> = HReadSeek(<Data file> , <Item> , <Sought value> [, <Options>])
<Result>: Boolean (optional) Corresponds to: - True if the sought record was found and read. The file buffer is loaded with the data of the record found. In this case, HError is set to 0 and HFound is set to True.
- False in the following cases:
- error while accessing the file (unable to read for example). HError returns an error code. HErrorInfo returns more details about the error. In this case, HFound cannot be used.
- the access to the file was performed but no record was found. In this case, HError is set to 0 and HFound is set to False.
Caution: In this case, the file buffer cannot be used.
<Data file>: Character string (with or without quotes) Name of data file, HFSQL view or query used. <Item>: Character string (with or without quotes) Name of item on which the search will be performed. For an exact-match search, this parameter can correspond to a non-key item.
<Sought value>: Type corresponding to the value Value of sought item. <Options>: Optional constant (or combination of constants) Used to configure:- the lock mode applied to the sought record.
- the type of search performed.
| | hLockWrite | Lock in write mode: the record currently read can be read by another application but it cannot be modified by another application. The lock mode is ignored if a query is used. | hLockReadWrite | Lock in read/write: the record currently read cannot be read or modified by another application. The lock mode is ignored if a query is used.
| 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 (constant not specified).
| hLimitParsing | | 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.
| hNoRefresh | |
This page is also available for…
|
|
|
| |
| Consulta usando chave primária ou estrangeira |
|
| HReset(t002_repostas) IF HReadSeek(t002_repostas, T002_Questionario_ID, Questionario_ID, hIdentical) = True THEN achou = True ELSE achou = False END
|
|
|
|
| |
| |
| |
|
| Outros exemplos de usar o Hreadseek com chave composta |
|
| HReset(t002_repostas) BufChaveComposta is Buffer = HBuildKeyValue(t002_repostas,T002_ChaveComposta, Questionario_ID, Pergunta_ID,Cliente_ID,Profissionais_ID) IF HReadSeek(t002_repostas,T002_ChaveComposta,BufChaveComposta,hIdentical) = True THEN achou = True ELSE achou = False END
Ou a mesma consulta pode ser feita assim:
HReset(t002_repostas) IF HReadSeek(t002_repostas,T002_ChaveComposta, [Questionario_ID, Pergunta_ID,Cliente_ID,Profissionais_ID] ,hIdentical) = True THEN achou = True ELSE achou = False END
|
|
|
|
| |
| |
| |
|
| BUSCA EM CHAVE COMPOSTA MISTA COM TEXTO E NUMERO |
|
| //BUSCA EM CHAVE COMPOSTA MISTA COM TEXTO E NUMERO ok is boolean
valorNovo = gnOrdem + 1
gsFruta = """"+gsFruta+""""
bufSearch is Buffer = HBuildKeyValue(t000_frutas,t000_kunica, gsFruta, gnOrdem)
IF HReadSeekFirst(t000_frutas,t000_kunica,bufSearch) = True IF HFound(t000_frutas) = True t000_frutas.t000_ordem = valorNovo ok = HModify(t000_frutas) END END |
|
|
|
| |
| |
| |
|
| | //Busca com Hreadseek ja posiciona o ponteiro no primeiro registro //Se fizer com Hexecutequery ou HexecuteSqlQuery é necessário dar um //for para movimentar o ponteiro para o primeiro e próximos registros
// search for the login in the file HReadSeek(GPU_08_Users,Login,Lower(EDT_Login))
// if the user exists IF HFound(GPU_08_Users) THEN // initialize the controls EDT_FormerPassword=GPU_08_Users.Password // changes the plane MyWindow..Plane=3
END |
|
|
|
| |
| |
| |
| |
| |
| |
| | |
|