Reads a record in a data file according to a given record number. This read mode is called "Direct access". The record read is loaded in memory. HState
is used to find out the record status (active, crossed or deleted).
In most cases, HRead is used to position in the data file in order to perform a read loop by specifying the record number.
Several cases may occur after the call to HRead:
- the specified record number does not exist (greater than the total number of records or negative): no reading is performed and HOut returns True.
- the specified record number does not exist anymore (crossed record, deleted record, ...): no read operation is performed and HOut returns False.
Use HState to find out the record status.
- the data file is empty: HOut returns True.
- the function tries to lock a record that is already locked in read-only: HErrorLock returns True and HOut returns True.
Locks are only managed on HFSQL Client/Server data files or data files handled by a Native Access. An HFSQL Mobile record cannot be locked. Indeed, the operating system of Pocket PC does not allow you to lock records.
Access by JDBC: The management of locks is not available for databases accessed by JDBC.
This function can be used with the data files (indexed or not) and with the HFSQL views.
// Sequential browse to display the name of all customersi is int
FOR i = 1 _TO_ HNbRec(Customer, hStateAll)
IF HState() = hStateActive THEN
Info("Customer name: " + Customer.Name)
<Result> = HRead([<Data file> [, <Record number> [, <Options>]]])
- True if the record was read,
- False if an error occurred (lock, end of data file, etc.): the record is not read. HError is used to identify the error.
<Data file>: Optional character string (with or without quotes)
Name of HFSQL data file, view or query used.
If this parameter corresponds to an empty string (""), HRead will use the last data file used by the last HFSQL management function (function starting with "H").
<Record number>: Optional integer
Number of the record to read.
If this parameter is not specified (or if it is equal to 0 or to the hCurrentRecNum
handles the current record.
reads the current record. You cannot specify a record number other than the current one. To specify the current record number, use the hCurrentRecNum
Access by JDBC: HRead
reads the current record. You cannot specify a record number other than the current one. To specify the current record, use the hCurrentRecNum
<Options>: Optional constant
Configures the lock set on the record read by HRead:
|hLockNo||No lock (even if HStartLock was called): the record can be read or modified by another application during the reading.|
|hLockWrite||Lock in write mode: the record currently read can be read by another application but it cannot be modified by another application.|
|hLockReadWrite||Lock in read/write: the record currently read cannot be read or modified by another application.|
Locks are managed only on HFSQL Client/Server data files or on data files handled by a Native Connector. An HFSQL Mobile record cannot be locked. Indeed, the operating system of Pocket PC does not allow you to lock records.
The lock options are ignored. Use the lock functions (HLockRecNum
) kept for backward compatibility.
The lock options will have no effect if the locks are not supported by the OLE DB provider or by the Native Connector.
Access by JDBC: This parameter is ignored.
The memos associated with the record can be automatically read (or not) when reading the record. HSetMemo
is used to customize this automatic read operation.
If the memos are supported, the associated text memos are read when the record is read. The binary memos are read only when they are explicitly used (HExtractMemo
The current record number is returned by HRecNum
. The first record found in the data file is record #1.