Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Adding Fields To Tables
Message
 
À
29/10/2002 01:29:48
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00716324
Message ID:
00716327
Vues:
13
In addition to the other replies, you can write a program, go through a list of DBFs (if this is your case) and do something like ** Be sure to back up **
set safety off
FOR i = 1 to alen(adir())
use (ADIR(i)) exclusive        && open file for exclusive use
copy to tmp structure extended && Create a DBF structure file
copy all to dbfBack            && Copy the data to a backuo
use                            && Close cuurent dbf being modified
erase (ADIR(i))                && I think this works
use tmp exclusive              && open the structure dbf
append blank                   && Add a record for field description
repl field_name with "NewField",field_type with "C",field_len with 30 && etc
create (ADIR(i)) from tmp      && Created a header with new field with original name
use (ADIR(i)) exclusive        && open empty file with new field
append from dbfBack            && Add the data - new field is empty
use                            && CLose
ENDFOR
BE SURE TO TEST THIS ON ONE FILE FIRST - I DIDN'T :)


>I have about 100 copies of an app I need to add new fields to some tables in each app.
>
>Can I add a new field, specifying its name, type etc to a table via some code without having to go into the table structure and doing it manually on each table?
>
>Thank you!
Imagination is more important than knowledge
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform