Deletes all records from a data file, an HFSQL view or a query. The records are deleted logically and physically. They cannot be restored.
The following operations are performed:
- the records are deleted: the records are not referenced in the index anymore. The data is not kept.
- the indexes (corresponding to the keys of the records) are deleted from the index file.
- the memos associated with the records are deleted from the memo file.
- the automatic identifiers are re-initialized.
Caution: the integrity is not checked.
WINDEV, WINDEV Mobile and WEBDEV propose an automatic management of errors for the following types of errors: Duplicate error, integrity error, password error, modification conflict error and status error during modification conflict, lock error. For more details, see Assisted HFSQL error handling
// Clear data file without re-creating it
<Result> = HDeleteAll(<Data file>)
- True if the records have been deleted,
- False if a problem occurred (locked record, record in transaction, ...). HErrorInfo is used to identify the error.
<Data file>: Character string
Name of HFSQL data file, HFSQL view or query used.
Deleting records from a query
If the query was created by using the hModifyFile constant, HDeleteAll deletes the records from the source of the query.
Deleting records from an HFSQL view
HDeleteAll deletes the records from the view but it does not delete the records from the data file used for the view.
Deleting records from a transaction
HDeleteAll does not delete the records found in a transaction (canceled or validated).
Benefits compared to a loop for deleting records
To delete the records from a data file, you can also set a loop for deleting the records (HDelete
). For example:
FOR EACH CustNum OF Orders
has the following advantages:
- the process is faster,
- the size of empty data file is smaller.
Advantage compared to HCreation
To delete the records from a data file, you also have the ability to use HCreation
Using HDeleteAll has the following advantages:
- Deletion possible even if users are connected to the data file.
- Automatic management of HFSQL errors.