Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Verify if a field already exists in a table
Message
De
06/07/2007 12:58:40
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Divers
Thread ID:
01238247
Message ID:
01238270
Vues:
24
>>>Hi everyone..
>>>
>>>How can I verify if a field already exists in a table?...
>>>Need to create it if doens´t....
>>>
>>>Thanks in advance
>>>Carlos Burgos
>>
>>Carlos, here you go:
>>
>>llFoundIt        = .F.
>>lnFC            = FCOUNT()
>>For I = 1 to lnFC
>>  If FIELD( I ) = lcFieldILookFor
>>      llFoundIt = .T.
>>  EndIf
>>EndFor
>>
>>If not llFoundIt
>>  ... Code to create field in table
>>EndIf
>>
>>
>>Terry
>
>Why not get out of the loop once you found it? Though it would be using "premature exit" :)

You're right. I meant to put an EXIT in there, although it breaks my fundamental rules, it's not too bad in a little loop like this. I was in a hurry to get he soln out before all you vultures descended but:

1. I was too late anyway as about 5 of you had already jumped on it
2. There were far more succinct soln.s anyway (although not as readible or obvious the process)

Woe is me! :-)
- Whoever said that women are the weaker sex never tried to wrest the bedclothes off one in the middle of the night
- Worry is the interest you pay, in advance, for a loan that you may never need to take out.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform