Click or drag to resize

DbPack Function

X#
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.19
Syntax
 FUNCTION DbPack() AS LOGIC
Request Example View Source

Return Value

Type: Logic
TRUE if successful; otherwise, FALSE.
Remarks

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.
Examples
The following example uses DBPack() with an aliased expression to remove from a file all records that have been marked for deletion:
X#
1Address->DBPack()
2// Operate on the Address alias
See Also