Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to compare and update master table?
Message
From
04/05/2006 14:11:01
 
 
To
04/05/2006 13:49:09
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 7 SP1
OS:
Windows Server 2003
Miscellaneous
Thread ID:
01119103
Message ID:
01119307
Views:
18
This message has been marked as a message which has helped to the initial question of the thread.
>Oh No! It's dangerous. I prefer replace only the records modified.

Why dangerous? If you're worried, back up the original before you overwrite it. It seems to me that you want the "master" table to be exactly the same as the "temp" - if so, an overwrite is the surest way to achieve this.

If you really want to update manually you can use a general approach like this:
SELECT ;
  * ;
  FROM Master ;
  UNION ;
  SELECT ;
    * ;
    FROM Temp ;
  INTO CURSOR Changed

* The UNION clause by default removes duplicate rows. You will be left with a list of rows that are either:
* 1. Present in MASTER but not in TEMP
* 2. Present in TEMP but not in MASTER
* 3. Present in both tables, but different
Assuming you have a primary key on each table, you can scan the "Changed" cursor and update appropriately.
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform