Duplicate records 
Author Message
 Duplicate records

What is the best way to duplicate a record ?


Mon, 17 Feb 2003 10:35:19 GMT  
 Duplicate records
The easiest way is with a variant array, e.g.:

procedure DupRecord(const DataSet: TDataSet);
var
  Fields: array of Variant;
  i: Integer;
begin
  SetLength(Fields, DataSet.FieldCount);
  for i := 0 to DataSet.FieldCount - 1 do
    Fields[i] := DataSet.Fields[i].AsVariant;
  DataSet.Insert;
  for i := 0 to DataSet.FieldCount - 1 do
    DataSet.Fields[i].AsVariant := Fields[i];
end;



Quote:
> What is the best way to duplicate a record ?



Wed, 18 Jun 1902 08:00:00 GMT  
 Duplicate records
how about using sql:
    insert into table (select * from table where key = 'xxx')
assuming the key is unique, of course
Quote:

> What is the best way to duplicate a record ?



Tue, 18 Feb 2003 01:10:53 GMT  
 Duplicate records
Hei! 2 good answers! Thanks a lot!
I guess I'll go with Avegaart option. It's more general, and I've been
having speed problems with LocalSQL and large Tables with LARGE Memos,
but for Remote SQL Drew has a point.
I tought that the BDE *must* have some internal duplicate function-that was
the reason for my question. Thanks again.

J.P.



Tue, 18 Feb 2003 22:00:46 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. duplicate records in join

2. Handling Duplicate records

3. Using SQL to delete duplicate records

4. Tracking duplicate records?

5. Duplicate records in Interbase

6. Duplicating Records

7. Duplicating records D4 & Paradox

8. How to Duplicate Records with TTable Component

9. duplicate records in TDBGrid

10. Duplicate record problem D3 C/S

11. Duplicate record problem

12. Insertion of Duplicate Records

 

 
Powered by phpBB® Forum Software