Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Compare two identical tables?
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00506435
Message ID:
00506971
Views:
13
SELECT table1
SCATTER NAME oTable1

SELECT table2
SCATTER NAME oTable2


*To break it out for printing the differences, you could try something like:

lcChangeString = SPACE( 0 )

IF COMPOBJ( oBeforeChange, oAfterChange )
* No changes made. Do nothing, unless you want something to happen.
ELSE
FOR i = 1 TO FCOUNT( )
lcTable1 = "oTable1." + FIELD( i )
lcTable2 = "oTable2." + FIELD( i )

IF &lcTable1. <> &Table2.
DO CASE
CASE TYPE( FIELD( i ) ) = "N"

lcChangeString = lcChangeString + " Field " + FIELD( i ) + " Changed from " ;
+ ALLTRIM( STR( &lcTable1. ) ) + " to " + ALLTRIM( STR( &lcTable2. ) ) ;
+ CHR(13)

CASE TYPE( FIELD( i ) ) = "D"

lcChangeString = lcChangeString + " Field " + FIELD( i ) + " Changed from " ;
+ ALLTRIM( DTOC( &lcTable1. ) ) + " to " + ALLTRIM( DTOC( &lcTable2. ) ) ;
+ CHR(13)

OTHERWISE

lcChangeString = lcChangeString + " Field " + FIELD( i ) + " Changed from " ;
+ ALLTRIM( &lcTable1. ) + " to " + ALLTRIM( &lcTable2. ) ;
+ CHR(13)

ENDCASE
ENDIF
ENDFOR
ENDIF

? lcChangeString


Oh yeah, if you have memo fields, you might want to SCATTER MEMO NAME oTable to include the memo fields, and maybe add other CASE's for other data types.

Good Luck,
John

P.S. sorry about the ugliness of the code, just did it real quick. Also, I don't know how to make it appear neat on these pages.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform