Duplicate record in TDBF lazarus / 16-Databases ---------------------------------------------------------------------- WTDdallas · 2016-08-11 03:42 Is there a way to duplicate a record in TDBF, other that one field at a time? ---------------------------------------------------------------------- howardpc · 2016-08-11 08:57 You can call AppendRecord(). But of course, that is a wrapper  routine that internally deals with each field, one at a time. How else could the values of the individual fields in the record be copied? ---------------------------------------------------------------------- WTDdallas · 2016-08-11 20:58 I found "TDataSet.GetCurrentRecord"  that "Copies the data for the current record in a memory buffer" But I cant find the way to move the buffer back, into a new record? ---------------------------------------------------------------------- mangakissa · 2016-08-12 06:36 If you mean creating a new record on the existing table you can't . The recordpointer moves to the end of the table and creates a new recordpointer for insert. In this case you have to create by your own. Something like this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure dubrecord;var MyRecord : array of variants;     index : integer; begin  //place current record into the array  for index := 0 to table1.fields.count - 1 do  begin     setlength(Myrecord,(index + 1);     MyRecord[index] := table1.fields[index].Value;  end;  //create a new record and read the array  table1.append;  for index := low(MyRecord) to high(MyRecord) do    table1.fields[index].value := MyRecord[index];  table1.post;  end;end; This is not working with unique indexes. ---------------------------------------------------------------------- Thaddy · 2016-08-12 12:03 If you need exact duplicates, field for field and in the same table, it is time, no: long overdue!, to normalize your database... If it is to copy the same record to another table there should be MyRecord.Assign If it isn't ask for it to be implemented ---------------------------------------------------------------------- WTDdallas · 2016-08-12 13:32 Quote from: mangakissa on August 12, 2016, 08:36:34 amIf you mean creating a new record on the existing table you can't . The recordpointer moves to the end of the table and creates a new recordpointer for insert. In this case you have to create by your own. Something like this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure dubrecord;var MyRecord : array of variant;     index : integer; begin  //place current record into the array  for index := 0 to table1.fields.count - 1 do  begin     setlength(Myrecord,(index + 1));     MyRecord[index] := table1.fields[index].Value;  end;  //create a new record and read the array  table1.append;  for index := low(MyRecord) to high(MyRecord) do    table1.fields[index].value := MyRecord[index];  table1.post;end; This is not working with unique indexes. That Worked, with corrections.  Thanks ---------------------------------------------------------------------- mangakissa · 2016-08-16 06:49 Quote from: Thaddy on August 12, 2016, 02:03:39 pmIf you need exact duplicates, field for field and in the same table, it is time, no: long overdue!, to normalize your database... /quote] What's the definition of duplicates. If I want to copy a sales order with only a difference of the week, should it be wrong and have I to normalize my database? ---------------------------------------------------------------------- Thaddy · 2016-08-16 07:02 Quote from: mangakissa on August 16, 2016, 08:49:07 am If I want to copy a sales order with only a difference of the week That's a difference... is it? Can you read? No need to normalize. I was talking about EXACT duplicates, what is the case here. Although there is a case to be made to have a date separated out. Depending on your needs. Third degree we call that https://en.wikipedia.org/wiki/Third_normal_form