Board index » delphi » Finding identical records in different tables

Finding identical records in different tables

I'm trying to compare record in two identically structured  tables as
part of an import routine. I thought that I could iterate through the
table's fields like this:

for x := 0 to (Table1.FieldCount - 1) do
        if Table1.Fields[x].Value <> Table2.Fields[x].Value then
                {do some stuff}

but Fields is of the abstract type TField,  which does not have a
"Value"  property. So the code above won't compile. Is there a quick &
easy  way of doing this and while keeping the code generic?

I know I can test the Field[x].DataType property and then Typecast
accordingly, but this seems like something I should be able to
accomplish in a few lines of code.

Thanks for any help.

Peter Kott
p...@mars.superlink.net

 

Re:Finding identical records in different tables


Copy the tables and change the primary key for both tables to the fields
you are comparing. Add one of the tables to the other, or try to insert
the records from one of tables into the other. The first method will
probably generate a CHANGED table or one of the other temporary tables
Paradox generates in these cases on the identical records and the latter
will generate key violations.
I hope this helps.

Other Threads