Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Compare and Update/Add if new
Message
De
31/05/2002 06:51:37
Mike Yearwood
Toronto, Ontario, Canada
 
 
À
30/05/2002 16:50:24
Lynette Tillner
Associated Valuation Services
Modesto, Californie, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00663202
Message ID:
00663327
Vues:
20
Hi Lynette

You should have a primary key on both tables.

The changed record part is a bit hard...
SELECT * FROM <ACCESSTABLE> WHERE <Fox Table.PK> IN 
(SELECT <Access Table.PK> FROM <Access Table>) AND ;
(
<Fox Table.Field1> <> <Access Table.Field1> OR ;
<Fox Table.Field2> <> <Access Table.Field2> OR ;

etc.

) INTO TABLE CHANGED.DBF
I'm using OR between the field comparisons because the first one that evaluates to .T. will cause the record to be included without checking the other fields. This means you should put the most likely changed fields first. The only pitfall with this method is the command length and the number of fields.

The add part is easy.
SELECT * FROM <ACCESSTABLE> WHERE <Fox Table.PK> NOT IN 
(SELECT <Access Table.PK> from <Access Table> ) INTO TABLE NEWRECS.DBF
Then you just append from NEWRECS.DBF

>I know this has been done a thousand times before, but not by me.
>
>I need to compare an existing table against a table of imported data (from access) and update the fields in the existing table if a record matches or add an new record if there is no match.
>
>Can anyone point me to a good example using views for such a process in VFP 6.0??????
>
>Thanks!
>
>Lynette
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform