packTable( )
Packs a Standard table by removing all deleted rows.
Syntax
<oRef>.packTable(<table name expC>)
<oRef>
The database in which the table exists.
<table name expC>
The name of the table you want to pack.
Property of
Database
Description
For DBF (dBASE) tables, packTable( ) removes all the records in a table that have been marked as deleted, making all the remaining records contiguous. As a result, the records are assigned new record numbers and the disk space used is reduced to reflect the actual number of records in the table. Adding an autoincrement field will automatically pack the DBF table.
For DB (Paradox) tables, packTable( ) removes all deleted records and redistributes the remaining records in the record blocks, optimizing the block structure.
To refer to a Standard table, you can always use the default database in the default session by referring to it through the databases array property of the _app object. For example,
_app.databases[ 1 ].packTable( "Customer" )
A couple observations regarding the packTable( ) method:
The packTable( ) method returns true or false to indicate whether the packing operation was succesfull.
Packing is a maintenance operation that requires exclusive access to the table. The packTable( ) method will fail - return false - if someone else has the table open.
The packTable( ) method can return a value of true without any records actually being deleted. A return value of true only indicates the operation encountered no errors. It does not imply that records were deleted. If no records were marked as deleted, the packTable( ) method will return true as long as it does not encounter any errors.
In order to catch any errors that might occur, it is recommended that packTable( ) be used in a try/endtry construct.