Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Drop Column - complicated problem
Message
 
 
To
30/11/2000 23:42:48
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00447719
Message ID:
00448127
Views:
12
>>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.
>

>Thank you for the kind words :)
>One command to drop all fields is the way to go. Especially with 5M records. In my test with 100K records, it took 6 seconds to drop each field individually and 2 seconds to drop both at once.
>Here's the test code I used. Setup for the test.
Create Database test
>Create Table test (ctest c(10), bogus c(10) primary key, bogus2 c(10))
>Index On ctest Tag ctest
>Index on bogus2 Tag bogus2
>Index on ctest+bogus2 Tag bogus3
>Do While Reccount()   Store Sys(2015) To m.ctest, m.bogus, m.bogus2
>  Insert Into test From Memvar
>EndDo
To run test: DropFields("test","bogus,bogus2")
** DropFields.prg
>LParameters tcTable, tcDropList
>Local llError, lcCommand
>Use (tcTable) Exclusive
>tcDropList = [,] + tcDropList
>tcDropList = Strtran(tcDropList, [,], [ drop column ])
>lcCommand = [Alter table ] + tcTable + tcDropList
>
>On Error llError = .T.
>&lcCommand
>Do While llError
>  AError(laError)
>  If laError[1,1] = 1531 && cannot drop field because of index
>    lcTag = laError[1,3]
>    ? "deleting tag ",lctag && just for messaging
>    Delete Tag (lcTag)
>    llError = .F.
>    &lcCommand
>  Else
>    Exit
>  EndIf
>EndDo
>If llError
>  ** Exited
>  AError(laError)
>  MessageBox("Error: " + Transform(laError[1,1])+Chr(13)+;
>    laError[1,2], 48)
>EndIf
>On error
btw, I've noticed in your code samples that you have the syntax coloring - do you have something you run that through before posting it, or do you take the time to do it by hand?


Trey,

First of all, thanks a lot for the test program. I trust you, so I'll go ahead and will code in the program ModifyStructure.

Regarding test coloring (tccc..., Mike Helland forbbids me to say his name aloud, so somebody with MH initials :) while ago wrote a program called mhHTMLCode, created Words table (BTW, don't know, how, and this table should be adjusted, when VFP7 will come) and posted it here in Files section. This program works fine except that it colorizes words in the string also, e.g.:
"File is not found"
,
while it should be
"File is not found"
Therefore I made my own version of this program, which doesn't have this problem. If you send me a message to my work address (click on the envelope), I'll send this program to you and include you in UT people group, which I created in my address book (since I didn't have your address in my Address Group, I didn't include you).
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform