Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 6 of 6 total
Thread Compare Records in different tables
Wed, Mar 27 2013 11:10 AMPermanent Link

John Taylor

Is there a way , other than iterating through know field values, to compare
a record in one table to a record in another table , the two tables having
identical structure ?

I've searched everything I can find in the manual, doesn't appear to be any
"built-in" function or method call to do this.

Thanks
JT
Wed, Mar 27 2013 12:13 PMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

John

>Is there a way , other than iterating through know field values, to compare
>a record in one table to a record in another table , the two tables having
>identical structure ?
>
>I've searched everything I can find in the manual, doesn't appear to be any
>"built-in" function or method call to do this.


Not that I'm aware of. I just used to iterate through Fields.Count

Roy Lambert [Team Elevate]
Wed, Mar 27 2013 12:18 PMPermanent Link

Raul

Team Elevate Team Elevate


There is a "RecordHash" system field that is a MD5 hash for the record.
However it does not get updated for BLOBs and other fields stored
outside main row so it might or might not work for you.

For generic solution you'd have to compare field by field (or use
RecordHash and then compare the fields that are not part of RecordHash
manually).

Raul



On 3/27/2013 11:10 AM, John Taylor wrote:
> Is there a way , other than iterating through know field values, to
> compare a record in one table to a record in another table , the two
> tables having identical structure ?
Wed, Mar 27 2013 12:51 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

John,

<< Is there a way , other than iterating through know field values, to
compare a record in one table to a record in another table , the two tables
having identical structure ? >>

No, but it's really simple to do.  Here is the function that we use in our
test framework (works with queries or tables):

function CompareDataSets(DataSet1: TDBISAMDataSet; DataSet2:
TDBISAMDataSet): Boolean;
var
  I: Integer;
begin
  Result:=True;
  with DataSet2 do
     begin
     if (RecordCount <> DataSet1.RecordCount) or
        (FieldCount <> DataSet1.FieldCount) then
        begin
        Result:=False;
        Exit;
        end;
     First;
     DataSet1.First;
     while (not EOF) do
        begin
        for I:=0 to FieldCount-1 do
           begin
           if (Fields[I].IsNull <> DataSet1.Fields[I].IsNull) or
              (Fields[I].Value <> DataSet1.Fields[I].Value) then
              begin
              Result:=False;
              Exit;
              end;
           end;
        Next;
        DataSet1.Next;
        end;
     end;
end;

Tim Young
Elevate Software
www.elevatesoft.com
Wed, Mar 27 2013 1:11 PMPermanent Link

John Taylor

Thanks for the replies, iterating over the fields it is

JT

"Tim Young [Elevate Software]" <timyoung@elevatesoft.com> wrote in message
news:468DCC6F-CD93-4740-AED9-8377E54F1BA6@news.elevatesoft.com...
> John,
>
> << Is there a way , other than iterating through know field values, to
> compare a record in one table to a record in another table , the two
> tables having identical structure ? >>
>
> No, but it's really simple to do.  Here is the function that we use in our
> test framework (works with queries or tables):
>
> function CompareDataSets(DataSet1: TDBISAMDataSet; DataSet2:
> TDBISAMDataSet): Boolean;
> var
>   I: Integer;
> begin
>   Result:=True;
>   with DataSet2 do
>      begin
>      if (RecordCount <> DataSet1.RecordCount) or
>         (FieldCount <> DataSet1.FieldCount) then
>         begin
>         Result:=False;
>         Exit;
>         end;
>      First;
>      DataSet1.First;
>      while (not EOF) do
>         begin
>         for I:=0 to FieldCount-1 do
>            begin
>            if (Fields[I].IsNull <> DataSet1.Fields[I].IsNull) or
>               (Fields[I].Value <> DataSet1.Fields[I].Value) then
>               begin
>               Result:=False;
>               Exit;
>               end;
>            end;
>         Next;
>         DataSet1.Next;
>         end;
>      end;
> end;
>
> Tim Young
> Elevate Software
> www.elevatesoft.com
Sat, Apr 20 2013 5:04 AMPermanent Link

Iztok Lajovic (1)

John,

when reading your post it came to my mind that it could be usefull for
somebody to have an utility that can compare two files and display only
records that are different. Some time ago I wrote such program and I put it
in elevatesoft.public.dbisam.binaries group.

Regards,
Iztok Lajovic
Image