Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Comparing one table to another
Message
 
To
26/11/2002 13:41:19
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00727145
Message ID:
00727201
Views:
28
>Lets say you have two table Table1 and Table2
>you can take table1 record by record and Scatter Name oT1Flds
>oT1Flds will have a property for every field in the table
>Do the same with Table2 and now you can do a record to record match based on field to field
>
>lnFlds = ADBF(laFlds,"Table1")
>Select Table1
>Scan
> Scatter Name oT1Flds
> lcKey = oT1Flds.field1 && field1 = key fld (or whatever the key field(s) should be)
> If Seek(lcKey,"Table1","Index1")
> Select Table2
> Scatter Name oT2Flds
> For xx = 1 To lnFlds
> *** compare oT1Flds.fieldname with oT2Flds.fieldsname (fieldname = laFlds[xx,1])
> EndFor
> Select Table1
> EndIf
>EndScan
>-------------------------
>
>This is the "down and dirty" version. Let me know if this helps or if you want to bounce it back and forth some more.

You don't really need to compare all the fieldnames in FOR loop. It's easier to use COMPOBJ() function:
lRecordsAreIdentical = COMPOBJ(oT1Flds, oT2Flds)
Nick Neklioudov
Universal Thread Consultant
3 times Microsoft MVP - Visual FoxPro

"I have not failed. I've just found 10,000 ways that don't work." - Thomas Edison
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform