Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Drop Column - complicated problem
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00447719
Message ID:
00447831
Views:
21
>>Hi everybody,
>>
>>I'm changing structure of the table programmatically and I want to drop some columns (delete fields). The problem here, that I need to be sure, this field in not uses in any Index Expression (and Index Filter expression), otherwise I have an error. Therefore, I have to check, if field (call it FieldA) is used in Index Expression or Index Filter Expression and if it is, delete this tag as well.
>>
>>The problem I see with this approach is: (in theory), suppose, I have fields called FieldA and FieldAB. I want to delete FieldA and leave FieldAB. If I would check Index Epr and Index Filter Expr for 'FieldA' $ IndexEpr, I'll find both cases (TagA & TagAB and delete both). This is the problem, associated with this idea. Therefore, when I re-create indexes, I will have to re-create one additional index (deleted by this code) and this would take time.
>>
>>Do you have some suggestions regarding this problem? May be there is a better way?
>>
>>Thanks a lot in advance.
>
>I've always been an advocate of leaving things alone... is there any specific reason the fields need to be removed?

Yes. We found, that bunch of fields are non needed. For instance, we have two work files structures: BldMstr and BldMstrP. BldMstr has all fields, which are in the other tables + bunch of work fields. It's a big flat table. We have a small subset of this table called BldMstrP. In this table there is no need for Transaction and Credit fields, only Property fields should be here. Yesterday we cleaned up the structure of BldMstrP (deleted fields from DataDictionary). So today I ran ModifyStructure program and found this problem. Anyway, I already fixed this program to allow this check and delete tags, which use field, that would be deleted. I decided not to complicate my life (and, I believe, it would be really hard to write the code this way), so I just check IndexExpr and Index FilterExpr for Field Name $ IndexExpr and if it's true, I delete this tag. Of course, if I have fields, for example, LstSlDate and Date, and I want to delete field Date, but leave LstSlDate and I have Indexes like:
LstSlDate and Date, both of them would be deleted and then first re-created. This is the downside. But I don't see an easy way to find out, that first index uses LstSlDate and the second - just Date.

Other than that, I solved this problem.

Hi again Wayne,

First time I could not send this message, so I have time to think about this problem more. I think, it could be solved with WSH Regular Expression parser (I have to deeply dig into the docs to write it correctly, though).

Basically, there are just few choices:
#define SYMBOLS ' +-/\(),' && These symbols could be used in index expression (seems, I didn't miss anyone)
Pseudo-code
any of SYMBOLS+fieldname+any of SYMBOLS  $ space(1)+IndexExpr+space(1)
Now I should think about realization of this idea. Also there are few choices: 1)WSH 2)chrtran 3)loop

I'll think about it more, but I got the idea.

Yes, it's very efficient to explain a problem in UT, because it forces your brain to work harder :)

BTW, if you have another ideas or you can help with the implementation of this idea - you're really welcome...

Thanks in advance.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform