Hello,
thanks to Kevin Parson, who told me the pack could be done with
'dbiDoRestucture' (BDE), I found out the following on packing tables:
If you don't want to use BDE, you can imitate the packing of a table by
creating a new table on runtime, copy all valid records to the new table
and rename and reopen the table.
The folowing indicates how to create a similar table on runtime:
uses DB, DBTables, StdCtrls;
procedure TForm1.Button1Click(Sender: TObject);
var
tSource, TDest: TTable;
begin
TSource := TTable.create(self);
with TSource do begin
DatabaseName := 'dbdemos';
TableName := 'customer.db';
open;
end;
TDest := TTable.create(self);
with TDest do begin
DatabaseName := 'dbdemos';
TableName := 'MyNewTbl.db';
FieldDefs.Assign(TSource.FieldDefs);
IndexDefs.Assign(TSource.IndexDefs);
CreateTable;
end;
TSource.close;
end;
{From: Lloyd's help file}
Of course, as I said, DBE provides a function to do the same:
put BDE in the 'uses' section.
Before calling this PackTable, make sure the table is active and exclusive.
procedure PackTable(Table: TTable);
var
Props: CURProps;
hDb: hDBIDb;
TableDesc: CRTblDesc;
begin
// Get the table properties to determine table type...
Check(DbiGetCursorProps(Table.Handle, Props));
// Blank out the structure...
FillChar(TableDesc, sizeof(TableDesc), 0);
// Get the database handle from the table's cursor handle...
Check(DbiGetObjFromObj(hDBIObj(Table.Handle), objDATABASE,
hDBIObj(hDb)));
// Put the table name in the table descriptor...
StrPCopy(TableDesc.szTblName, Table.TableName);
// Put the table type in the table descriptor...
StrPCopy(TableDesc.szTblType, Props.szTableType);
// Set the Pack option in the table descriptor to TRUE...
TableDesc.bPack := True;
// Close the table so the restructure can complete...
Table.Close;
// Call DbiDoRestructure...
Check(DbiDoRestructure(hDb, 1, @TableDesc, nil, nil, nil, FALSE));
Table.Open;
end;
{from borlands FAQ}
--
To reply, remove 'spam' from:
spameavo...@iae.nl