Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Code to compare all fields in two tables
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00943805
Message ID:
00943897
Vues:
17
>I read that thread and I do not think that it doesas I want.
>
>Table1 and Table2 are identical, just two different copies. They have a unique key. Want to sync and end up with Table1 as my master table that has the changes and adds from both tables (records are not deleted). Prior to the sync, Table1 could have records that are not in Table2 and visa versa. Table1 could have changes to record with record_key = '1' and Table2 could also have changes to record with record_key = '1' also. When they both make changes to the same record, I would want to identify the different field values with the field name and print a report for reconciliation.
>
>I was thinking of reading each record in the tables sequentially to find the new records added from table2 so that they could be added to table1. Also read each record for when the key is the same to find out if changes were made in table1, table2, or both.
>
>So my thought is that during the sync process, to have a sync_date written to the tables (actually written once to a higher level table). If the mod_dt is greater than the sync_dt, then I know that updates were made since the last sync. If only one record mod_dt > synd_dt, then I will write that record to table1. If both records mod_dt is > sync_date then both people made changes to the record since the last sync. Then I will use the record with the most current sync_date, but I also want to interogate each field to find the differences and print a reconciliation report.
>
You may add three new fields to your tables Date_Created, Date_LastModified, Date_deleted, if it's not too much overhead for you. In our system we used ModiDate and ModiType (Char 1 - "C","D","A", where C- changed, A - added, D - deleted).

1) First using UNION you create records from Table1 + all records, which are only in Table2 and the records, which are changed in both tables

2) You can identify ID duplicates and these records are the records which were changed in both copies. You need to proceed them accordingly.

My colleague created an update utility for our own purposes. I do not know, how general the code is and would you be allowed to check that code to decide for yourself. But I guess, it would not hurt to ask. Her UT member # 011472
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform