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. <Source>.State
is used to find out the record status (active, crossed or deleted).
In most cases, <Source>.Read 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 <Source>.Read:
- the specified record number does not exist (greater than the total number of records or negative): no reading is performed and <Source>.Out returns True.
- the specified record number does not exist anymore (crossed record, deleted record, ...): no read operation is performed and <Source>.Out returns False.
Use <Source>.State to find out the record status.
- the data file is empty: <Source>.Out returns True.
- the function tries to lock a record that is already locked in read-only: HErrorLock returns True and <Source>.Out returns True.
This function can be used with the data files (indexed or not) and with the HFSQL views.
// Sequential iteration to display the name of all customers
i is int
FOR i = 1 _TO_ Customer.NbRec(hStateAll)
IF Customer.State() = hStateActive THEN
Info("Customer name: " + Customer.Name)
<Result> = <Source>.Read([<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.
<Source>: Type corresponding to the specified source
Name of the HFSQL data file, view or query used.
<Record number>: Optional integer
Number of the record to read.
If this parameter is not specified (or is equal to 0 or to the hCurrentRecNum
will read the current record.
reads the current record only. You cannot specify a record number other than the current one. To specify the current record number, use the hCurrentRecNum
<Options>: Optional constant
Configures the lock set on the record read by <Source>.Read:
|hLockNo||No lock: the record can be read or modified by another application during the reading.|
|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.|
The lock options are ignored. Use locking functions (<Source>.LockRecNum
) 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.
Looping through a data file
The memos associated with the record can be automatically read (or not) when reading the record. <Source>.SetMemo
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 (<Source>.ExtractMemo