Hi all,
I'm trying to create a clone table at run-time and use the following
code. It creates the clone table all right, but it doesn't create the
index with it.
Any ideas?
Ps. This routine creates only the assigned index (supposing it works).
Is there a way to create ALL indexes without having to specify which you
want?
Thanks for your help.
function CreateCloneTable(sDbaseName, sSourceTableName, sDestTableName,
sIndexName : string; vtTableContent : tTableContent) : boolean;
{Function:
Create a copy of the source table in the destination table (including
any indexes etc.
Entry Parameters:
sDbaseName = name of dbase
sSourceTableName = source table name
sDestTableName = destination table name
sIndexName = name of secondary index to create
vtTableContent = defines empty table or copy data
Returns:
True if completed successfully.}
var
tblSource : TTable;
tblDest : TTable;
bmBatchMove : TBatchMove;
begin
result := true;
try
tblSource := TTable.create(nil);
tblDest := TTable.create(nil);
with tblSource do
begin
databaseName := sDBaseName;
tableName := sSourceTableName;
IndexName := sIndexName;
end;
with tblDest do
begin
databaseName := sDbaseName;
tableName := sDestTableName;
IndexName := sIndexName;
end;
with tblDest do
try
close;
tblSource.fieldDefs.update;
fieldDefs.assign(tblSource.fieldDefs);
tblSource.IndexDefs.update;
indexDefs.assign(tblSource.indexDefs);
createTable; // create the clone table
// copy data to the new table if required
if vtTableContent = tCopyData then
begin
bmBatchMove := TBatchMove.create(nil);
with bmBatchmove do
begin
source := tblSource;
destination := tblDest;
mode := batAppend;
execute;
end;
bmBatchMove.free;
end;
except
result := false;
end;
tblSource.free;
tblDest.free;
except
result := false;
end;
end;{CreateCloneTable}
John Christenhusz
POSTEC DATA SYSTEMS Ltd.
PO Box 302-230
Auckland, New Zealand
E-mail: [EMAIL PROTECTED]
Phone: 09-415.8803
Fax: 09-415.9042
application/ms-tnef