Board index » delphi » How do I rewrite slightly modified records?

How do I rewrite slightly modified records?

I am working on a project which is converting thousands of records of
data from a dBase database to a Paradox database with some mods to the
records in between them using Delphi 3.  I take a record that I have just
read in the dbase table, process and assign values to fields in the
Paradox table and post the record.  Easy enough right.  In some instances
I will need to immediately  write a new  record into the receiving table
only changing the key and one field (of 30) from the last record. All
other fields should be the same.  I am used to using 'append' to add the
records to the paradox table, but 'append' causes all the fields of the
new record to be empty.  This would cause me to have to reprocess the
entire record only to really change the one field from the last posted
record.  Does any one how to just change the one field and post a new
record, just like the last posted record? In other words what's the
command or logic for "Write a record just like the last one except change
the key and this one field in the new record"?

If it helps, I am using table.fieldbyname('field').as...  to assign the
field values. Stuck! Please Help!

John W. Mayer

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet

 

Re:How do I rewrite slightly modified records?


Quote
In article <880492067.7...@dejanews.com> maye...@ams.iix.com writes:
>I am working on a project which is converting thousands of records of
>data from a dBase database to a Paradox database with some mods to the
>records in between them using Delphi 3.  I take a record that I have just
>read in the dbase table, process and assign values to fields in the
>Paradox table and post the record.  Easy enough right.  In some instances
>I will need to immediately  write a new  record into the receiving table
>only changing the key and one field (of 30) from the last record. All
>other fields should be the same.  I am used to using 'append' to add the
>records to the paradox table, but 'append' causes all the fields of the
>new record to be empty.  This would cause me to have to reprocess the
>entire record only to really change the one field from the last posted
>record.  Does any one how to just change the one field and post a new
>record, just like the last posted record? In other words what's the
>command or logic for "Write a record just like the last one except change
>the key and this one field in the new record"?
>If it helps, I am using table.fieldbyname('field').as...  to assign the
>field values. Stuck! Please Help!

How about snapshotting the field-values into a TStringList and using them to
preload values into the next record that you add?  e.g.

        for I := 0 to FieldCount - 1 do begin
           table.Fields[i].AsString := LastValues[i];
        end;
        << make changes >>
        table.Append;
        for I := 0 to FieldCount-1 do begin
           lastValues[i] := table.Fields[i].AsString;
        end;

Other Threads