Board index » delphi » Copying records in current table to the same table

Copying records in current table to the same table

I need to be able to copy/append a record in a table to the same table.
So I am using TBatchmove with recordcount set to one and set to batcopy.
I am copying the data to a temporary file, changing the Id to keep it
unique and then append it back to the master table. I have about 4-5
tables that are linked to the master table that I need to link back to
the new record with default data. So I am going to do the same with
those tables.
 Does anyone have an easier way to copy a record in the same table? I
figured this was the easiest way, not requiring a lot of code.
 I'm using Delphi 3 accesing dBASE tables.

Thanks,
Kevin W. Archibald

 

Re:Copying records in current table to the same table


You could use two TTable components on the same dBase File and then do
your own copy operation by assigning the fields from source to dest table.

create destTable identical to srcTable

insert new record into destTable

for all fields in srcTable do

    Assign srcTableField to destTableField

Assign new unique key to primary index of desttable

Post new record

Kevin W. Archibald schrieb in Nachricht <353CD50E.C235C...@novell.com>...

Quote
>I need to be able to copy/append a record in a table to the same table.
>So I am using TBatchmove with recordcount set to one and set to batcopy.
>I am copying the data to a temporary file, changing the Id to keep it
>unique and then append it back to the master table. I have about 4-5
>tables that are linked to the master table that I need to link back to
>the new record with default data. So I am going to do the same with
>those tables.
> Does anyone have an easier way to copy a record in the same table? I
>figured this was the easiest way, not requiring a lot of code.
> I'm using Delphi 3 accesing dBASE tables.

>Thanks,
>Kevin W. Archibald

Other Threads