Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ALTER TABLE and INSERT INTO not working
Message
From
13/12/2006 04:37:21
Michael Gass
Instructional Software, Inc.
Kirkland, Washington, United States
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
ALTER TABLE and INSERT INTO not working
Miscellaneous
Thread ID:
01177095
Message ID:
01177095
Views:
52
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)
Next
Reply
Map
View

Click here to load this message in the networking platform