Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Select statement wont honour set fields to ?
Message
De
03/04/2006 09:00:21
Mike Yearwood
Toronto, Ontario, Canada
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8 SP1
Divers
Thread ID:
01108144
Message ID:
01109924
Vues:
24
>Thanks Mike.Thats a good idea.
>what i fianally did was i get all columns into a cursor and i've a routine that drops columns i dont need from the cursor.
>i mean something like
>alter table mytable drop column fld1

That's exactly what I tried to warn you against. SELECT * from table brings over more columns of data than you need which is a waste of time and LAN throughput. On top of that you are then performing some operation to exclude those columns.

It's very rare anyone would want fields from just one table - of course that presumes good data modeling. I mentioned creating a routine that returns all fields except a specified list. Such a routine would be useful in some cases. I built this one just now. It requires the name of an open cursor/table etc. To do multiple tables, call it more than once.

Use it like this:
TEXT TO m.lcSQL TEXTMERGE NOSHOW
SELECT ;
  <<FExcept("MyTable","thisfield, thatfield")>>, ;
  <<FExcept("MyTable2","anotherfield")>> ;
  FROM MyTable ;
  INNER JOIN MyTable2 ON somefield = someotherfield ;
  INTO CURSOR c_Testing
ENDTEXT
&lcSQL.
Here's the routine. I tested it for the simplest/obvious stuff.
*FExcept.PRG
LPARAMETERS m.tcSourceAlias, m.tcExcludeFieldList
IF PCOUNT()<2
  ERROR 1229 && too few args
ENDIF

IF VARTYPE(m.tcSourceAlias) # "C" ;
  OR VARTYPE(m.tcExcludeFieldList) # "C" ;
  OR EMPTY(m.tcExcludeFieldList)
  ERROR 11
ENDIF

IF NOT USED(m.tcSourceAlias)
  ERROR 13
ENDIF

LOCAL ;
  m.lcExtraCommasFieldList, ;
  m.lcReturnedFieldList, ;
  m.lnFieldCount, ;
  m.lnCounter

STORE "," + UPPER(m.tcExcludeFieldList) ;
  + "," TO m.lcExtraCommasFieldList

STORE "" TO ;
  m.lcReturnedFieldList
  
LOCAL ARRAY ;
  m.laFields[1]

m.lnFieldCount = AFIELDS(m.laFields,m.tcSourceAlias)

FOR m.lnCounter = 1 TO m.lnFieldCount
  IF "," + laFields[m.lnCounter,1] ;
    + "," $ m.lcExtraCommasFieldList
    LOOP
  ENDIF
  m.lcReturnedFieldList = ;
    m.lcReturnedFieldList ;
    + laFields[m.lnCounter,1] + ","
ENDFOR m.lnI

m.lcReturnedFieldList = ;
  LEFT(m.lcReturnedFieldList,;
  LEN(m.lcReturnedFieldList) - 1)

RETURN m.lcReturnedFieldList
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform