Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Compare Structures of 2 Tables Tip
Message
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Compare Structures of 2 Tables Tip
Divers
Thread ID:
00579912
Message ID:
00579912
Vues:
69
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform