PRODUCT : Paradox Engine NUMBER : 1004 VERSION : All OS : All DATE : October 19, 1993 PAGE : 1/2 TITLE : Packing a Database When the Paradox Engine deletes records out of a table, it doesn't resize the file; it simply marks the space of the record as available. Thus, as you add records, over time you get a bigger data file. Once you've deleted some records you can pack them by either of two methods. The first is to use PXTblCopy(), which will copy only non-deleted records to a new table. Rename the old table and name the new table with the old table name. You can delete the old table, which you renamed, if there were no errors. The second strategy is to use a PXCopyTableStruct() type of function to make a new database (without a primary index), and then add records from the original table from the bottom up. Then, index the new table. The important point is to first add the records to the new table and then add the primary index to the new table. This will insure that as little as possible space is used by the data being written to the new table. Note that packing a database followed by adding records (when the table has a primary index) requires a significant amount of table reorganization when records are inserted into the table. An unpacked table will still have room for table additions without table reorganization. Thus, if you are still frequently adding records to a table, you may choose to not pack the table. Packing a table is normally only useful for tables that are not being changed regularly. The following steps show how to pack a Paradox 4.0 table which contains BLOb, or Memo fields: I) Use PXTblClose() to close the table ( cannot be open by any application ) II) Use PXKeyDrop() to delete all indexes ( use the PXKeyQuery() function to get information regarding secondary indexes ). III) Use PXTblCopy() to copy the table to a temporary table. IV) Use PXTblEmpty() to empty the original table. V) Use PXTblAdd() to copy the temporary table to the origional table. VI) Use PXTblDelete() to delete the temporary table. VII) Use PXKeyAdd() to add the indexes to the table. PRODUCT : Paradox Engine NUMBER : 1004 VERSION : All OS : All DATE : October 19, 1993 PAGE : 2/2 TITLE : Packing A Database DISCLAIMER: You have the right to use this technical information subject to the terms of the No-Nonsense License Statement that you received with the Borland product to which this information pertains.