Board index » delphi » duplicate a record to an other record in the same table
yvon labbee
![]() Delphi Developer |
Sun, 13 May 2001 03:00:00 GMT
|
yvon labbee
![]() Delphi Developer |
Sun, 13 May 2001 03:00:00 GMT
duplicate a record to an other record in the same table
I am new in Delphi 3. I have a table with many fields for each record. I
want to duplicate a record to a new one in the same table. I have to change my first field before appending because I have an index on Please help with an exemple Thank you Yvon Labbee |
Michael Glat
![]() Delphi Developer |
Sun, 13 May 2001 03:00:00 GMT
Re:duplicate a record to an other record in the same tableThe easiest way to do that is to declare variables for each of the fields in the table, load the fields from the record you want to duplicate, call append for the dataset and put the variables into the new record. var field1 := table1.FieldByName('YourField1').AsString; This is a very crude and simple example but it should give you some kind of -- Quoteyvon labbee wrote in message <73h2nn$b...@forums.borland.com>... |
Wes
![]() Delphi Developer |
Sun, 13 May 2001 03:00:00 GMT
Re:duplicate a record to an other record in the same tableQuoteyvon labbee wrote in message <73h2nn$b...@forums.borland.com>... Paradox tables. You don't have to change the key value before you copy the record, you have The following example has a couple of potential problems, for example if you With the previous warning in mind, this procedure bypasses the need to This example creates a variant array with the same number of elements as the It then appends a new record and iterates through the elements of the array, Note that you will need to change the key or indexed field value either with procedure TForm1.Button1Click(Sender: TObject); recordarray := VarArrayCreate([0, table1.fieldcount], varVariant); // because variant array indexes are zero based // iterate the fields of the table copying the field values to the for i:= 0 to table1.fieldcount -1 do // append new record // change key field value here by code or by user input As with any method or procedure someone gives you, you should take this Wes |
Richard Have
![]() Delphi Developer |
Sun, 13 May 2001 03:00:00 GMT
Re:duplicate a record to an other record in the same tableIf the schemas are identical, you can do something like: Table2.Edit; .AsString works with NULLs; .Value does not. This won't work with blob Cheers Quoteyvon labbee wrote: |
Team
![]() Delphi Developer |
Sun, 13 May 2001 03:00:00 GMT
Re:duplicate a record to an other record in the same tableOne way to copy a record is to use two TTable components, one pointing to the old record and one pointing to the new record. Then use: DestTbl.Insert; -- |
Dave Ril
![]() Delphi Developer |
Mon, 14 May 2001 03:00:00 GMT
Re:duplicate a record to an other record in the same tableQuote> If the schemas are identical, you can do something like: How about: I saw this somewhere (not sure where) - will it work with NULLs and Blobs? Dave Riley |
1. Duplicating a record in a Paradox table
2. Deleting All But The First Duplicate Record From A Table
4. Duplicate records in interbase table.
5. Duplicate records in Interbase table
6. Finding duplicate records in a table...
7. How to prevent duplicate records in paradox table?
8. Duplicating records in multiple tables?