Mike Yearwood
Toronto, Ontario, Canada
Hi there
Ed's right. There are a great number of ways to do this. I took some code like this once and greatly increased its performance). The time dropped from 4 hours to 15 minutes. I proposed that the code should try to determine what records needed changing and what records were new before moving the data. The floppy in my case included a vast majority of records that hadn't changed.
The code below needs some explaining. "st" and "tt" are aliases (SourceTable and TargetTable). I'd consider copying the file from the floppy to a temp directory and renaming it to anything but PEOPLE (I chose "sourcepeople"). The first SQL gets only those records that have changed. It will have good performance if you organize the field comparisons according to frequency of change of the fields. The part in parentheses uses ORs to make VFP stop checking the record once any change is detected. If the name changes most often, the comparison stops at name and that record is selected into the changepeople table. The drawback to this approach is its dependant on the structure, but its very fast. The first SQL gets large quickly if the number of fields is great. You should list all fields to ensure a check is made. There should be a break even point where the number of fields causes so many comparisons that copying the entire record would be as fast, but I never bothered looking for this.
Assuming dnumber is unique, do this...
select * from sourcepeople st, people tt where st.dnumber = tt.dnumber and ;
(st.name # tt.name or st.address # tt.address or st.phone # tt.phone or st.zip # tt.zip) into table changepeople
*changepeople should now be the current work area
set order to dnumber in people
scan
scatter memo memvar
select people
=seek(changepeople.dnumber)
gather memo memvar
*Scan doesn't require you to reposition the alias
endscan
select * from sourcepeople where dnumber not in (select dnumber from people) into table newpeople
select people
append from newpeople
HTH
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement