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.

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.

In PHP, the management of locks is not available.

In Java, during an access by JDBC, the management of locks is not available for the databases accessed by JDBC.

// Find the first record for which // the CUSTOMER name is MOOREHReadSeekFirst(CUSTOMER, NAME, "MOORE")IF HFound(CUSTOMER) = False THEN Error("Customer not found") RETURNELSE // Continue the process on the customer named MOOREEND

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.

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.

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.

Lock in write-only. Operating mode equivalent to the hLockWrite constant.

This constant is not available.

Access by JDBC: This constant is not available.

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.

This constant is not available.

Access by JDBC: This constant is not available.

hLockNo

No lock (even if HStartLock was called): the record can be read or modified by another application during the reading.

This constant is not available.

Access by JDBC: This constant is not available.

Versions 17 and laterhForwardOnly

New in version 17hForwardOnly

hForwardOnly

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.

hGeneric

Generic search (see the Notes)An exact-match search is performed by default (constant not specified).

hLimitParsing

The 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).

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.

This variable cannot be used.

By default, the browse performed after HReadSeekFirst ignores the filter.

hNoRefresh

HReadSeekFirst does not refresh the content of table or query. The query is not re-run if possible. All the saved positions are stored.

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.

The management of locks is not available.

Access by JDBC: The management of locks is not available for the databases accessed by JDBC.

The lock options will have no effect if the locks are not supported by the OLE DB provider or by Native Access.

The lock mode specified by HReadSeekFirst will remain effective during the calls to HReadPrevious and HReadNext.

Generic search (mainly on the Character String items): Finds all 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 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 value

Options

HReadSeekFirst positions on the record.

HFound returns

HOut returns

Explanations

Davon

1

True

False

Davon exists.The end of data file was not reached yet.

Davo

1

False

False

Davo does not exist. Position on the first greater value (Davon).The end of data file was not reached yet.

Davi

hGeneric

8

True

False

Davi 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.

Davi

The record was not found (no move, the current record does not change).

False

False

Davi does not exist.The end of data file was not reached yet.

Norbert

The record was not found (no move, the current record does not change).

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.

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.

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.

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:

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.

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.

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).

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)ENDTableDisplay(TABLE_QRY_RELACAO_EMPRESAS,taReExecuteQuery)TableSelectPlus(TABLE_QRY_RELACAO_EMPRESAS,_indice)