Board index » delphi » Batch Move Failed

Batch Move Failed

I used the Batch Move vcl to move data older than 6 months to an auxiliary
table. The data was copied to the aux table, but was never deleted from the
initial table. Why is this? Anyone?

 

Re:Batch Move Failed


Quote
checkit wrote:

> I used the Batch Move vcl to move data older than 6 months to an auxiliary
> table. The data was copied to the aux table, but was never deleted from the
> initial table. Why is this? Anyone?

There is no mode to delete records from the source table, you'll have to
code that yourself...

From the help:  

Applies to

TBatchMove components

Declaration

property Mode: TBatchMode;

Description

The Mode property specifies what the TBatchMove object will do:

Property        Purpose

batAppend       Append records to the destination table. The destination table
must already exist. This is the default mode.

batUpdate       Update records in the destination table with matching records
from the source table. The destination table must exist and must have an
index defined to match records.

batAppendUpdate If a matching record exists in the destination table,
update it. Otherwise, append records to the destination table. The
destination table must exist and must have an index defined to match
records.

batCopy Create the destination table based on the structure of the
source table. The destination table must not already exist--if it does,
the operation will delete it.

batDelete       Delete records in the destination table that match records in
the source table. The destination table must already exist and must have
an index defined.

Re:Batch Move Failed


BatchMove does not automatically do what you require.

Presumably you use batAppendUpdate to move records to the aux table.
After you have done that try reversing the source and destination
tables, change mode to batDelete and execute. All records in the
original (main) table that match records in the aux table will be
deleted.

That should produce the result you require.

(practice on copies of data first !!!)

Regards

John. M ( VectorCalc Ltd.)

Re:Batch Move Failed


BatchMove copies records.  It will not delete the source records. You will
have to code the deletion yourself.  One way to do so is to query the
records you want to delete and BatchMove the queryied records to a temporary
table. From there BatchMove the records to the archive table.  Now use a
DELETE query to delete all records in the source table that match records in
the temporary table, then empty or delete the temporary table.

--
Bill

(TeamB cannot answer questions received via email.)
(To contact me for any other reason remove nospam from my address)

Other Threads