Click or drag to resize

Functions.DbPack Method

Remove all records marked for deletion from a database file, rebuild all active orders, and recover all physical space occupied by the deleted records.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.18
Request Example View Source

Return Value

Type: Logic
TRUE if successful; otherwise, FALSE.
By default, this function operates on the currently selected work area. It can be made to operate on an unselected work area by specifying it within an aliased expression or by calling the overload that accepts a workarea parameter (a workarea number or alias ). This function requires that the current database be open in exclusive mode (see SetExclusive()).
If this condition is not met when the function is invoked, a runtime error is raised.
Otherwise, the operation proceeds and, upon termination, resets the record pointer to the first logical record in the current work area. Warning! DBPack() does not create backup files. You may want to make a backup of the file before issuing this function call; otherwise, you will not be able to recover deleted records. Tip: Packing large database files can be a time-consuming process and is, therefore, not recommended in a high-volume transaction application. By modifying the application design, you can remove the necessity of physically removing records from the database file. Simply filter the deleted records with SetDeleted(TRUE) or DBSetFilter(!Deleted()) and reuse deleted records instead of adding new ones.
The following example uses DBPack() with an aliased expression to remove from a file all records that have been marked for deletion:
2// Operate on the Address alias
See Also