Importing Data from Another Table

From RAD Studio
Jump to: navigation, search

Go Up to Using BDE-enabled datasets Index

Note: The Borland Database Engine (BDE) has been deprecated, so it will not be enhanced. For instance, BDE will never have Unicode support. You should not undertake new development with BDE. Consider migrating your existing database applications from BDE to dbExpress.

You can use a table component's BatchMove method to import data from another table. BatchMove can:

  • Copy records from another table into this table.
  • Update records in this table that occur in another table.
  • Append records from another table to the end of this table.
  • Delete records in this table that occur in another table.

BatchMove takes two parameters: the name of the table from which to import data, and a mode specification that determines which import operation to perform. The following table describes the possible settings for the mode specification:

BatchMove import modes

Value Meaning

batAppend

Append all records from the source table to the end of this table.

batAppendUpdate

Append all records from the source table to the end of this table and update existing records in this table with matching records from the source table.

batCopy

Copy all records from the source table into this table.

batDelete

Delete all records in this table that also appear in the source table.

batUpdate

Update existing records in this table with matching records from the source table.


For example, the following code updates all records in the current table with records from the Customer table that have the same values for fields in the current index:

Table1.BatchMove('CUSTOMER.DB', batUpdate);
Table1->BatchMove("CUSTOMER.DB", batUpdate);

BatchMove returns the number of records it imports successfully.

Warning: Importing records using the batCopy mode overwrites existing records. To preserve existing records, use batAppend instead.

BatchMove performs only some of the batch operations supported by the BDE. Additional functions are available using the TBatchMove component. If you need to move a large amount of data between or among tables, use TBatchMove instead of calling a table's BatchMove method. For information about using TBatchMove, see Using TBatchMove.

See Also