Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Comparing two tables
Message
De
22/08/2009 19:25:50
 
 
À
22/08/2009 18:56:19
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
Divers
Thread ID:
01419830
Message ID:
01419868
Vues:
71
Tracy --

Thanks for the code. That's more or less the track I took. I was hoping for a great utility that would do the work for me ...

As it happens, I had a report from a user than some number of fields (a few) had been zeroed out for a number of records. My search then was primarily to find fields with lots of changes, where the new value was zero. So, in fact, your suggestion with simply summary of differences by field was a really good start.



>I thought you were referring to the structures of the tables. For data, you could write something yourself and output it to a table or to a display in a form or to whatever - here's an example to get you started:
>
>
>clear
>CLOSE tables
>USE tableactive IN 0 ALIAS table1
>USE tablehistory IN 0 ALIAS table2
>select table1
>=AFIELDS(tafields,'table1')
>SET EXACT ON
>SCAN  && change this if you need to do a locate or seek in the 2nd table but you get the picture
>	*--Go to the correct record in both that should match (Locate, SEEK, etc. this example just goes by recno)
>	lnRecno = RECNO('table1')
>	GOTO lnRecno IN table2
>	FOR i = 1 TO ALEN(tafields,1)
>		DO CASE
>		CASE tafields(i,2) = "C" OR tafields(i,2) = "M"
>			SELECT table1
>			lxValue1 = UPPER(ALLTRIM(NVL(EVALUATE(tafields(i,1)),'')))
>			SELECT table2
>			lxValue2 = UPPER(ALLTRIM(NVL(EVALUATE(tafields(i,1)),'')))
>		CASE tafields(i,2) = "I" OR tafields(i,2) = "N"
>			lxValue1 = NVL(table1.&tafields(i,1),0)
>			lxValue2 = NVL(table2.&tafields(i,1),0)
>		*--Etc More CASE statements
>		ENDCASE
>		IF lxValue1 <> lxValue2
>			?  [Record: ]
>			?? ALLTRIM(STR(lnRecno))
>			?? [ Field: ] +tafields(i,1)+ [ Differ: ]
>			?? lxValue1
>			?? [ != ]
>			?? lxValue2
>		ENDIF
>	ENDFOR
>	SELECT table1
>	IF RECNO('table1') <> lnrecno
>		goto lnrecno IN table1
>	ENDIF
>ENDSCAN
>
>
>>Sergey --
>>
>>Looks to be like the download you referenced is not exactly what I am looking for -- it does a nice comparison of the structure of two tables, but, from what I am able to see, does not compare the actual data.
>>
>>Will try XML and Beyond Compare next
>>
>>>Jim,
>>>
>>>Check file #25036.
>>>Another option would be to convert tables to XML with CURSORTOXML() and use text compare utility of your choice. I would recommend BeyondCompare
>>>
>>>>I have copies of the same table as it existed last weekend and this weekend.
>>>>
>>>>Sometime between then and now, a number of fields for a number of records have been destroyed. At the moment I have no idea how this happened, which fields are involved, nor how many records got trashed.
>>>>
>>>>The file is of moderate size -- about 10,000 records for about 150 fields.
>>>>
>>>>Is there any handy utility that will help me identify changed fields and records between the two?
>>>>
>>>>Thanks in advance.
Jim Nelson
Newbury Park, CA
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform