Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ALTER TABLE and INSERT INTO not working
Message
De
13/12/2006 04:37:21
Michael Gass
Instructional Software, Inc.
Kirkland, Washington, États-Unis
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
ALTER TABLE and INSERT INTO not working
Divers
Thread ID:
01177095
Message ID:
01177095
Vues:
53
I'm trying to import data from previous versions of my software where tables have fewer fields than the current version. I want to add field names from the current tables to the older tables, so the names of fields for old and new match. Then "INSERT INTO" can move data from the old tables to the new tables. Well, that's the theory. Neither "ALTER TABLE" nor "INSERT INTO" works. I'm getting syntex errors. Does anyone have a suggestion?
LPARAMETERS curtable, oldtable
LOCAL old,cur,afieldname,afieldtype,afieldsize,zfieldtoadd
 
  old = FCOUNT(oldtable)
  cur = FCOUNT(curtable)

  SELECT (curtable)
  = AFIELDS(aTblStr,(curtable)) 
  DO WHILE old <= cur 
      imp = imp + 1
      afieldname  = aTblStr(imp,1)
      afieldtype  = aTblStr(imp,2)
      afieldsize  = aTblStr(imp,3)
      zfieldtoadd = afieldname + " " + afieldtype + ;
          "(" + LTRIM(STR(afieldsize)) + ")"
      SELECT (oldtable)
      ALTER TABLE (oldtable) add column &zfieldtoadd
  ENDDO

  SELECT (curtable)
  INSERT INTO (curtable) SELECT * FROM (oldtable)
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform