Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Drop Column - complicated problem
Message
 
 
À
30/11/2000 21:52:31
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00447719
Message ID:
00447857
Vues:
12
>>>Trap the error and drop the index. e.g.
Local llError
>>>Use mytable Exclusive
>>>On Error llError = .T.
>>>Alter Table mytable Drop Column myfield
>>>Do While llError
>>>  AError(laError)
>>>  If laError[1,1] = 1531 && cannot drop field because of index
>>>    lcTag = laError[1,3]
>>>    Delete Tag (lcTag)
>>>    llError = .F.
>>>    Alter Table mytable Drop Column myfield
>>>  Else
>>>    Exit
>>>  EndIf
>>>EndDo
>>>If llError
>>>  ** Exited
>>>  ** due to some other problem
>>>  AError(laError)
>>>  MessageBox("Error: " + Transform(laError[1,1])+Chr(13)+;
>>>              laError[1,2], 48)
>>>EndIf
>>
>>Hi Trey,
>>
>> This is a nice and simpler idea, which I just explained to Wayne :) The only problem here, that I constract my alter table command to delete all fields, which are no longer needed, e.g.
>>lcCommand=lcCommand+' drop column '+fieldname in a loop. I'm not quite sure, that error in this case would contain all offending indexes. Anyway, I have to check it (tomorrow). Currently I already implemented my own idea.
>>
>> Thanks again, Trey. (Though, to be absolutely true, I have thought about it too, but haven't thought it to the end :))
>
>I just tested this using 2 different fields with 3 different indexes and it worked just fine. I even tried it with a Primary Key - probably not a good real-world idea, but that worked too.

Great. Could you please post your test program for me to repeat? Did you try to create a one command line, then execute macro, or you delete field by field, as in your original idea. I guess, both approaches should work the same way, and I doubt, that the first will give speed benefit, because dropping fields is quite fast. Suppose, I have 5mln. records in a table and I want to drop, say, 4 fields. What is faster:
pseudo-code:
drop field1
drop field2, etc.
or lcDel='drop field 1 drop field2...'
&lcDel????

Of course, for adding or changing fields, it's much better to do it once, e.g. construct the long command rather than executing field by field altering, but for dropping fields I guess, there is no speed difference. Do you know the answer on this question?

Thanks again for your help. Your ideas are great support for me.
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