Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Nasty index, any better ideas?
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Nasty index, any better ideas?
Miscellaneous
Thread ID:
00817470
Message ID:
00817470
Views:
64
I have a data field of mixed alphanumeric that needs a specific sort order. I think this is enough points to illustrate. They are either all integer data points, or begin with an alpha and the rest is numeric. Example:

Unordered data: B16,16,C2,5,123,2,C21,D86,278,27,2796,B1,C22

Ordered data: 2,5,16,27,123,278,2796,B1,B16,C2,C21,C22,D86

Here's my quickly devised ordering method, call the field CatNumber (yeah, I know, yuck, this is not very elegant):

INDEX ON IIF(ISALPHA(SUBSTR(CatNumber,1,1)),;
1000*ASC(SUBSTR(CatNumber,1,1))+VAL(SUBSTR(CatNumber,2)),;
VAL(SUBSTR(CatNumber,1))) TAG CatNumber

The "1000" multiplier is big enough for all possible data points, BTW. It works, if a bit ugly, so why the problem? I'm doing a hobby-article for not very deep coders - people that have only MS Access available, IOW. And I don't find Access supporting the above solution. Anyone see any ideas that are simpler, and might work in Access? Just a "simpler vfp index" would be a good start for the Access stage...

(Note: I'm avoiding any possible less-standard vfp functions like LEFT, also, as part of this project.)
The Anonymous Bureaucrat,
and frankly, quite content not to be
a member of either major US political party.
Next
Reply
Map
View

Click here to load this message in the networking platform