Restores the file context that was saved beforehand (HSavePosition
): current record, filter, pointers.
HRestorePosition is used to restore:
- the number of the record used,
- the different pointers in the index (the position in the index is saved for each key),
- the current filter (only if the hRPFilter constant is specified).
This function can be used with the data files, HFSQL views or queries.
Note: From version 19, HFSQL is the new name of HyperFileSQL.
// Find a record
HReadSeekFirst(CUSTOMER, NAME, Name)
WHILE HFound(CUSTOMER) = True
// Saves the current context
nPos = HSavePosition(CUSTOMER, NAME)
// Check a customer with another name
HReadSeek(CUSTOMER, NAME, Name2)
IF HFound() = True THEN Counter = Counter + 1
// Restores the context
<Result> = HRestorePosition(<Position> [, <Option>])
- True if the specified position was restored,
- False otherwise. HError returns more details about the problem.
Position to restore. Value returned by HSavePosition.
<Option>: Optional constant (or combination of constants)
Used to configure the restore operation:
|hRPKeep||The position is not freed (other calls to HRestorePosition can be performed on this position).|
|The position is freed. The stored position is restored.|
|hRPFilter||Restores the filter implemented during the call to HSavePosition.|
|hRPHF5||If the stored position was deleted or modified, this position is still restored.|
If the hRPHF5 constant is not specified and if the backup was performed on several items, the positioning is performed according to the current record number during the call to HSavePosition.
This constant is not supported.
Access by JDBC: This constant is not supported.
This parameter is ignored: the position will be stored for all items on which a browse is in progress.
Caution: all the functions that open or close a data file reinitialize the context numbers (HCreation
If the record saved by HSavePosition
was deleted, HRestorePosition
keeps the current context but it will position on the record following the deleted record.
When reinitializing a browse, the positions saved on this browse are destroyed. The HFSQL engine is using the value of best item to attempt a new positioning. The best item is selected in the following preference order:
- Automatic identifier
- Unique key
- First key
- First item
The following functions reinitialize the browse:
- The number of calls to HSavePosition is not limited.
- You have the ability to nest HSavePosition and HRestorePosition for the same file.
Repositioning principle for Native Accesses
The record is restored from the internal cache of Native Access.
Caution: during the restore operation, no check is performed regarding the existence of record in the database (the record may have been deleted).
You have the ability to "force" the reading on the database by using HRead
. In this case:
- the record values will be read again in the database.
- if the record was deleted, the error 13 will be returned by Native Access: The current record cannot be found. It was modified or deleted from the data source.
Special cases: Native MySQL, DB2 and Informix Accesses
: After the call to HRestorePosition
generate a query to find the record following or preceding the restored record.