Hi Tristan

> I have one table (table a) which can get updated from another table of
> the same structure (table b).  Now there are records in table A that
> have been changed in table B, so we want to update these records from
> table B and import any new records.
>
> Pretty simple...  A scan with a scatter, seek, replace/append gather
> will do this.  The only thing is its ok, when just 1 person has table A
> open, but if someone else has it open, it slows right down.
>
> Am I being completely dumb and going about this the entirely wrong way?
>

I don't only do it with the scan as you're doing. It is too slow. I
use SQL to extract the records which have changed and the records
which are new. The ORs in the first query stop evaluating when the
first one is .T. so it's very fast.

select * from tablea src inner join tableb tgt on src.pk = tgt.pk where ;
src.field1 # tgt.field1 or src.field2 # tgt.field2 or
src.field3#tgt.field3 ... into cursor c_Edits

select * from tableB where pk  not in (select pk from tablea) into cursor c_Adds

select c_Edits
scan
  IF seek(c_Edits.pk,tableA,"PK")
    scatter name m.oRec
    select tableA
    gather name m.oRec
  ENDIF
endscan

select tableA
append from dbf("c_Adds")

hth


_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to