Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ALTER TABLE and INSERT INTO not working
Message
 
À
13/12/2006 04:43:30
Michael Gass
Instructional Software, Inc.
Kirkland, Washington, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01177095
Message ID:
01177098
Vues:
9
You will lose decimal points if you have fields like N(14,2). Try:
LPARAMETERS curtable, oldtable
LOCAL old,cur,afieldname,afieldtype,afieldsize,zfieldtoadd

  old = FCOUNT(oldtable)
  cur = FCOUNT(curtable)

  SELECT (curtable)
    = AFIELDS(aMyStruc, (curtable))  && structure array for currentfile
    do while old <= cur 
        old = old + 1
        afieldname  = aMyStruc(old,1)
        afieldtype  = aMyStruc(old,2)
        afieldsize  = aMyStruc(old,3)
        afielddeci  = aMyStruc(old,4)
        IF afielddeci # 0
            zfieldtoadd = afieldname + [ ] + afieldtype + [(] + TRANSFORM(afieldsize) + [,]+TRANSFORM(afielddeci) + [)]
        ELSE
            zfieldtoadd = afieldname + [ ] + afieldtype + [(] + TRANSFORM(afieldsize) + [)]
        ENDIF

        SELECT (oldtable)
        ALTER TABLE (oldtable) ADD COLUMN &zfieldtoadd
    ENDDO

    SELECT (curtable)
    INSERT INTO (curtable) SELECT * FROM (oldtable)
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform