Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Modify structure - any utility available?
Message
 
 
À
05/04/2001 16:18:48
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00492489
Message ID:
00492524
Vues:
18
>>Hi everyone,
>>
>>I have an assignment to change the order of the fields in a table with ~100 fields. Using Modify Structure for this would be very unsufficient. I have bunch of ideas how to simplify the process (simplest is to write a select statement with the correct order), but I'm wondering, if someone already created a UI for modifing structure?
>
>I'm curious as to why you want to do this.
>
>The only reason I can think of is to make the table more "readable" for maintenance programmers (i.e. logically group fields that "belong" together). If that's the case, and the table doesn't have PKs, relations etc. then your SELECT - SQL idea sounds pretty good.

The output from this table goes to SDF, so the field order is important
In the meantime I wrote this simple program to produce a field list in SQL. The next thing still would be manual to modify this program by cut/paste to change the order of the fields:
********************************************************************
*  Description.......: GetFieldList - produces a string with all fields listed
*  Calling Samples...: 
*  Parameter List....: tcFileName
*  Created by........: Nadya Nosonovsky 04/05/2001 03:46:19 PM 
*  Modified by.......: Nadya Nosonovsky 04/05/2001 04:06:09 PM
********************************************************************
lparameter tcFileName
#define CRLF chr(13)+chr(10)
if !empty(m.tcFileName) or vartype(m.tcFileName)<>"C"
   local lcAlias
   lcAlias=proper(alias()) 
   if !empty(lcAlias)
      m.tcFileName=lcAlias
   else
      =messagebox("Table name was not supplied!",48,"Required parameter is missing...")
      return .f.
   endif
endif
local lnSelect
lnSelect=select()
if vartype(lcAlias)="U"
   local lcAlias
   lcAlias=proper(juststem(m.tcFileName))
endif   
if !used(lcAlias)
   if !OpenTble(m.tcFileName,lcAlias)
       select (lnSelect)
       return .f.
   endif
endif
local lnFields, lcFieldStr, lnI
lcFieldStr="Select ;"+CRLF
lnFields=afields(laFields)
for lnI=1 to lnFields                     
    lcFieldStr=lcFieldStr+laFields[lnI,1]+iif(lnI=lnFields,"",",")+" ;"+CRLF
next
lcFieldStr=lcFieldStr+"FROM "+dbf(lcAlias)+";"+CRLF+ ;
          " INTO TABLE "+ ;
           addbs(justpath(dbf(lcAlias)))+"New"+lcAlias
strtofile(lcFieldStr,"ChangeStructure.prg")
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform