PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US

  • Generic search/Exact-match search
  • Search performed on a key item or on a non-key item
  • Performing a search on a composite key
  • Search on an array item
  • Search and filter
  • Browsing the records corresponding to a condition
  • Exact-match search in Access
  • Locks
  • Optimizing the browse operations
  • Native XML access
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Positions on the first record of a data file whose value for a specific item is strictly equal to a sought value (exact-match search). The record is read and the corresponding HFSQL variables are updated.
In most cases, HReadSeekFirst 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 HReadSeekFirst:
  • a record corresponding to the condition was found, locked (if necessary) and loaded in memory: HFound returns True.
  • if no record corresponding to the condition exists but if a record with a greater value is found: the record is read, HOut returns False and HFound returns False.
  • the data file is empty: no reading is performed, HOut returns True and HFound returns False.
  • the function tries to lock a record that is already locked in read-only: no reading is performed, HErrorLock returns True and HOut returns True.
    Note: An automatic management of lock errors and modification conflicts is performed by default (except in the code of stored procedures). This assisted management of errors can be customized or disabled at any time by HOnError.
HReadSeekFirst can be used with the data files, HFSQL views or queries.
Note: the search can be canceled by HCancelSeek.
Windows MobileJavaPHP Special case: management of locks:
  • Windows Mobile In Mobile, the management of locks is performed on the HFSQL Client/Server data files and on the data files handled by native access. A HFSQL Mobile record cannot be locked. Indeed, the operating system of Pocket PC does not allow you to lock records.
  • PHP In PHP, the management of locks is not available.
  • Java In Java, during an access by JDBC, the management of locks is not available for the databases accessed by JDBC.
Versions 15 and later
WINDEV MobileAndroid This function is now available for the Android applications.
New in version 15
WINDEV MobileAndroid This function is now available for the Android applications.
WINDEV MobileAndroid This function is now available for the Android applications.
Versions 17 and later
iPhone/iPad This function is now available for the iPhone/iPad applications.
New in version 17
iPhone/iPad This function is now available for the iPhone/iPad applications.
iPhone/iPad This function is now available for the iPhone/iPad applications.
Versions 18 and later
Android Widget This function is now available in Android Widget mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
New in version 18
Android Widget This function is now available in Android Widget mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
Android Widget This function is now available in Android Widget mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
Note: From version 19, HFSQL is the new name of HyperFileSQL.
Versions 21 and later
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
New in version 21
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
// Find the first record for which
// the CUSTOMER name is MOORE
HReadSeekFirst(CUSTOMER, NAME, "MOORE")
IF HFound(CUSTOMER) = False THEN
        Error("Customer not found")
        RETURN
ELSE
        // Continue the process on the customer named MOORE
END
Syntax
<Result> = HReadSeekFirst(<File Name> , <Item Name> , <Sought Value> [, <Options>])
<Result>: Boolean
  • True if the record was found (corresponds to the value returned by HFound).
  • False if a problem occurred. 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.
<File Name>: Character string (with or without quotes)
Name of HFSQL data file, view or query used.
<Item Name>: Character string (with or without quotes)
Name of item on which the search will be performed. This item can be a search key or not.
Hyper File 5.5 The search can only be performed on a 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.
hLockReadWriteLock 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.
OLE DB Lock in write-only. Operating mode equivalent to the hLockWrite constant.
PHP This constant is not available.
Java Access by JDBC: This constant is not available.
hLockWriteLock 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.
PHP This constant is not available.
Java Access by JDBC: This constant is not available.
hLockNoNo lock (even if HStartLock was called): the record can be read or modified by another application during the reading.
PHP This constant is not available.
Java Access by JDBC: This constant is not available.
Versions 17 and later
hForwardOnly
New in version 17
hForwardOnly
hForwardOnly
Native Accesses Constant that can only be used with Native Accesses.
Used to speed up the browse of data during a simple browse that does not use the following features:
  • Reading the previous record.
  • Modifying a record.
  • Saving position.
If one of these features is used, the result may differ from the expected one.
This constant can be used for example during a browse used to fill a memory table.
hGenericGeneric search (see the Notes)
An exact-match search is performed by default (constant not specified).
hLimitParsingThe browse will stop as soon as the last sought value is found or if no value corresponds to the search.
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 speed in Client/Server mode and on the external databases (accessed via OLE DB or via Native Accesses).
hKeepFilterThe 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.
Hyper File 5.5 This variable cannot be used.
By default, the browse performed after HReadSeekFirst ignores the filter.
hNoRefresh
OLE DBNative Accesses HReadSeekFirst does not refresh the content of table or query. The query is not re-run if possible. All the saved positions are stored.
Windows Mobile The management of locks is performed on the HFSQL Client/Server data files and on the data files handled by native access. A HFSQL Mobile record cannot be locked. Indeed, the operating system of Pocket PC does not allow you to lock records.
PHP The management of locks is not available.
Java Access by JDBC: The management of locks is not available for the databases accessed by JDBC.
OLE DBNative Accesses The lock options will have no effect if the locks are not supported by the OLE DB provider or by Native Access.
OLE DB The lock mode specified by HReadSeekFirst will remain effective during the calls to HReadPrevious and HReadNext.
To modify the lock mode, you must use:
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 "Martin" (for the NAME item), all records whose Name item starts with "Martin" will correspond to the search. Therefore, the record containing "Martinez" will correspond to the search (HFound returns True).
    Note: For backward compatibility with WINDEV 5.5, the generic search of an empty string ("") is equivalent to the use of HReadFirst.
  • 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:
Sought valueOptionsHReadSeekFirst positions on the record.HFound returnsHOut returnsExplanations
Davon1TrueFalseDavon exists.
The end of data file was not reached yet.
Davo1FalseFalseDavo does not exist. Position on the first greater value (Davon).
The end of data file was not reached yet.
DavihGeneric8TrueFalseDavi does not exist but the search is a generic search and Davies is found (among others).
The end of data file was not reached yet.
DaviThe record was not found (no move, the current record does not change).FalseFalseDavi does not exist.
The end of data file was not reached yet.
NorbertThe record was not found (no move, the current record does not change).FalseTrueNorbert does not exist.
Position on the first greater value (this value does not exist): the end of data file has been reached.
See the Hyper File 5.5 and 7: How to manage the space characters in the searches? table for more details

Search performed on a key item or on a non-key item

The search can be performed on a key item or a non-key item.
If the search is performed on a key item:
  • the search is fast and the result is sorted.
  • if the browse is continued by HReadNext, the next records will correspond to the values greater than or equal to the sought value. In this case, HOut must be checked after each read operation to find out whether the end of data file has been reached.
If the search is performed on a non-key item:
  • the selected item will appear in red in the code editor and a warning will be displayed in the "Compilation errors" pane.
    Note: The automatic completion proposes the key items only.
  • if the browse is continued by HReadNext, the next records will correspond to the values equal to the sought value.

Performing a search on a composite key

Several methods can be used to perform a search on a composite key:
1. Using a list of values
The following syntax is used to perform a search on a composite key:
HReadSeekFirst(<File Name>, <Name of Composite Key>,
[<Search Value of First Element of Composite Key>,
<Search Value of Second Element of Composite Key>, ...])
Example:
// Find the record
HReadSeekFirst(CUSTOMER, LASTNAME_FIRSTNAME, ["MOORE", "Vince"])
2. Using HBuildKeyValue
Example:
bufSoughtVal is Buffer = HBuildKeyValue(CUSTOMER, LASTNAME_FIRSTNAME, sLastName, sFirstName)
HSeekFirst(CUSTOMER, LASTNAME_FIRSTNAME, bufSoughtVal)
WHILE HFound(CUSTOMER)
        HDelete(CUSTOMER)
        HNext(CUSTOMER, LASTNAME_FIRSTNAME)
END
3. Using HConvert
To build the value of composite key without using HBuildKeyValue, you must:
  • fill the text components on their entire size with Charact(0).
  • convert the numeric components with HConvert.
Example:
MyCompositeKey = Complète(Customer.CustomerLastName, Dimension(Customer.LastName), Charact(0)) + ...
Complète(Customer.FirstName, Dimension(Customer.FirstName), Charact(0))
Hyper File 5.5 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), the filter is taken into account by the search only if the key used is identical.
To take this filter into account in the rest of browse (even if the search key is not optimized for the filter), use the hKeepFilter constant.
Hyper File 5.5 If a filter is enabled, the filter is ignored by the search.

Browsing the records corresponding to a condition

In most cases, HReadSeekFirst is used to position in the data file in order to perform a browse loop among the records corresponding to a condition. HReadNext and HReadPrevious are used to read the next and previous records corresponding to the condition.
To ignore the search while going to the next or previous record, use one of the following functions:
WINDEVWEBDEV - Server codeReports and QueriesAjaxUser code (UMC)OLE DBNative Accesses

Exact-match search in Access

To perform an exact-match search on an ACCESS database, we recommend that you use NoSpace if space characters are found at the end of sought value.
WINDEVWEBDEV - Server codeReports and QueriesiPhone/iPadWindows MobileUniversal Windows 10 AppAjaxUser code (UMC)HFSQLHFSQL Client/ServerHyper File 5.5OLE DBNative Accesses

Locks

The locks apply only when a record was found.
By default (no lock mode specified in <Options>), the record is not locked.
If a lock is requested (hLockWrite or hLockReadWrite constant), the record will be read only if this record is not already locked.
There is no need to specify a lock parameter if the data file is locked by HStartLock: the lock specified by HStartLock is automatically taken into account. To ignore the lock performed by HStartLock, use the hLockNo constant.
Reminder: A locked record can be unlocked by HUnlockRecNum.
OLE DBNative Accesses The lock options will have no effect if the locks are not supported by the OLE DB provider or by Native Access.
WINDEVWEBDEV - Server codeReports and QueriesiPhone/iPadUniversal Windows 10 AppAjaxUser code (UMC)HFSQLHFSQL Client/ServerHyper File 5.5OLE DBNative Accesses

Optimizing the browse operations

To optimize the time of the first browses performed on a data file, use HOptimize on this data file.
WINDEVWEBDEV - Server codeReports and QueriesUser code (UMC)Native Accesses

Native XML access

The behavior of HReadSeekFirst depends on HActivateAutoFilter and HDeactivateAutoFilter.
HActivateAutoFilter is enabled by default.
Therefore, to read the content of XML file, read the content of main file (the parent) then read the content of linked files (the children).
By default, when reading a file, a filter is automatically applied to the linked files in order to only read the records corresponding to the main file.
For example:
The email of this person can be retrieved when browsing the Person file.
To do so, all you have to do is position on the "Person" file and apply HReadSeekFirst to the "Email" file.
In this case, the record read in the "Email" file will correspond to the first email associated with the current record in the "Person" file.
If this mechanism is disabled (HDeactivateAutoFilter), the record read in the "Email" file will correspond to the first record found in the Email file (and not to the child of the record read in the "Person" file).
Components
WINDEVWEBDEV - Server codeReports and Queries wd230hf.dll
Windows Mobile wp230hf.dll
Java wd230java.jar
Linux wd230hf.so
Android wd230android.jar
Minimum required version
  • Version 9
This page is also available for…
Comments
Vamos a cambiar el registro.
//Aula 1153 WinDev Curso ErpAmarildo 11 - Tabela Codigo de Alteração

//Nessa aula de hoje
//vamos fazer a alteração do registro.

//En esta clase de hoy
//Vamos a cambiar el registro.

//In this class today
//Let's do the registry change.

IF TableSelect(TABLE_QRY_RELACAO_EMPRESAS)=-1 THEN RETURN
_indice is int=TableSelect(TABLE_QRY_RELACAO_EMPRESAS)
HReadSeekFirst(empresa,empresaID,TABLE_QRY_RELACAO_EMPRESAS.COL_EmpresaID)
IF HFound(empresa) THEN
Open(WIN_Form_empresa)
END
TableDisplay(TABLE_QRY_RELACAO_EMPRESAS,taReExecuteQuery)
TableSelectPlus(TABLE_QRY_RELACAO_EMPRESAS,_indice)
De matos
May 18 2017
Example
// adds a row into the looper
//by Boller - nome das janelas = GPU_WindowPages
//------------------------------------------------
ok is boolean = HReadSeekFirst(GPU_WindowPages,GPU_WindowPages.Name,sElementName,hKeepFilter)
IF ok = True AND HFound(GPU_WindowPages) = False
GPU_WindowPages.Name = sElementName
HAdd(GPU_WindowPages)
END
//------------------------------------------------
BOLLER
Apr. 24 2017
Como Pegar Saldo Anterior Caixa
1) Nessa aula de hoje, vou mostrar como
pegar o saldo incial do caixa.
2) Vamos ter um campo saldo inicial do caixa conta
3) vamos fazer uma query lendo os totais de entrada e saida
4) Vamos atualizar o saldo

//Qry_Saldo_caixa_Inicial
SELECT
SUM(caixa.valor_entradas) AS total_valor_entradas,
SUM(caixa.valor_saidas) AS total_valor_saidas
FROM
caixa
WHERE
caixa.id_empresa = {Parametro_empresa}
AND caixa.Caixa_contaID = {Parametro_contaID}
AND caixa.data_documento<{Parametro_data_inicial}

//
//Chama Rotina Saldo Caixa

saldo_caixa()

//Rotina Saldo Caixa

PROCEDURE saldo_caixa()

HReadSeekFirst(caixa_conta,caixa_contaID,gn_recebe_id_conta)
cy_saldo_inicial is currency=caixa_conta.saldo_inicial // Iniciar 100,00
qry_saldo_caixa_inicial.Parametro_contaID=gn_recebe_id_conta // 1
qry_saldo_caixa_inicial.Parametro_data_inicial=EDT_Data_Inicial // 10 01 2017
qry_saldo_caixa_inicial.Parametro_empresa=gnEmpresaCodigo // 1
HExecuteQuery(qry_saldo_caixa_inicial,hQueryDefault) // executando query
cy_saldo_entradas is currency=qry_saldo_caixa_inicial.total_valor_entradas
//vai somar todas entradas menores que a data inicial = 09 01 2017
cy_saldo_saidas is currency=qry_saldo_caixa_inicial.total_valor_saidas
//vai somar todas saidas menores que a data inicial = 09 01 2017
cy_saldo_inicial=cy_saldo_inicial+cy_saldo_entradas-cy_saldo_saidas
EDT_Saldo_Anterior=cy_saldo_inicial

http://windevdesenvolvimento.blogspot.com.br/2017/01/aula-1031-dicas-012-pegar-saldo.html

https://www.youtube.com/watch?v=xpqkboM8LFY
De matos
Jan. 13 2017
Exemplo HreadSeekFirst - Ncm
PROCEDURE ncm_estado_ler()
HReadSeekFirst(ncm_estado,chave_Ncm_classificacao_Uf,[material.ncm_classificacao,cliente.endereco_uf])
IF HFound(ncm_estado) THEN
info("existe")
ELSE
info("nao Existe")
END

//Blog com Exemplo e video
http://windevdesenvolvimento.blogspot.com.br/2015/11/windev-curso-144-chavecomposta.html
De matos AMARILDO
Jan. 23 2016