Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Code to compare all fields in two tables
Message
De
24/09/2004 17:29:38
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00943805
Message ID:
00945909
Vues:
16
Hi Brenda, I'm late on this thread. If you still need code on this, let me know.
If you have the code already, beware of the code using

SCATTER NAME ...
COMPOBJ(oRecord1, oRecord2)

as when the two fields in the two records hold the NULL value, then the comparison yields false.

>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.
>
>
>>See message #727212
>>
>>I would start from identifying the records which are different. I assume, you have the same IDs in both tables, but the rest of the data field could be different, right? Then I would try (from the top of my head):
>>
>>select *, "Copy 1" as TableName from Copy1 ;
>> UNION ;
>>select *, "Copy 2" as TableName from Copy2 ;
>>order by KeyFld into cursor curAll nofilter>
>>
>>select * from curAll where TableName = "Copy 2" into cursor curDifference >nofilter
>>Then you can proceed with curDifference and analyze each individual field.
>
>>>Does anybody have some code to compare to copies of the same table field by field. Want to produce a report that would list the differences. The report would print the record key, field name, value1, value2.
>>>
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform