Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Compare Structures of 2 Tables Tip
Message
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Compare Structures of 2 Tables Tip
Miscellaneous
Thread ID:
00579912
Message ID:
00579912
Views:
71
In VFP 7, comparing structures of 2 tables is now easier. The first step is to copy the EXTENDED structure of each table to tables. I did a search here for other solutions. They generally used afields and other stuff, but this solution seems so much easier. The procedure I created is for comparing Oracle tables so you would have to change COLUMN_NAME to FIELD_NAME:
   PROTECTED PROCEDURE CompareStructureData
      LPARAMETERS tcAlias1, tcAlias2
      IF RECCOUNT(tcAlias1)  RECCOUNT(tcAlias2)
         RETURN .f.
      ENDIF
      LOCAL lnSelect, llTheSame, lcFedCols, lcGISCols
      lnSelect = SELECT()

      SELECT * from (tcAlias1) ORDER BY column_name INTO CURSOR crsTempOne nofilter
      SELECT * from (tcAlias2) ORDER BY column_name INTO CURSOR crsTempTwo nofilter

      CURSORTOXML('crsTempOne', 'lcTempOne')
      CURSORTOXML('crsTempTwo', 'lcTempTwo')

      lcTempOne = lower(lcTempOne)
      lcTempTwo = lower(lcTempTwo)

      *!* Change the cursor name in the second XML string to be the same as in the
      *!* first string because this name is irrelevent to the structure comparison
      lcTempTwo = STRTRAN(lcTempTwo, 'crstemptwo', 'crstempone')

      IF SYS(2007, lcTempOne) = SYS(2007, lcTempTwo)
         llTheSame = .t.
      ENDIF
      USE IN crsTempOne
      USE IN crsTempTwo
      SELECT (lnSelect)
      RETURN llTheSame
   ENDPROC
Mark McCasland
Midlothian, TX USA
Next
Reply
Map
View

Click here to load this message in the networking platform