Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Compare and Update/Add if new
Message
From
31/05/2002 06:51:37
Mike Yearwood
Toronto, Ontario, Canada
 
 
To
30/05/2002 16:50:24
Lynette Tillner
Associated Valuation Services
Modesto, California, United States
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00663202
Message ID:
00663327
Views:
22
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform