Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is there another way to index a table?
Message
From
22/05/1999 14:52:38
 
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00221286
Message ID:
00221782
Views:
12
>>>>>Is there another way to index a table with
>>>>>using INDEX ON my_fld TO inx_name?
>>>>>
>>>>>I want to ORDER BY a group of records
>>>>>that are contained in a filter using SET FILTER TO something.
>>>>>I do not want to use INDEX TO or the SELECT statement.
>>>>>Any ideas?
>>>>
>>>>You have a bunch of options:
>>>>
>>>>(1) You can add a FOR clause to an index to filter the set of records available when that index is active. While the index can't be used for Rushmore optimization, it does provide the fastest sorted, filtered access to a table on a record by record basis without using a SQL Select to extract a cursor. Since the index only contains the records meeting the conditions of the FOR clause, you don't have the horrid performance hit moving from one filtered record to the next for a non-optimizable filter condition. Filtered indexes can be either standalone .IDX files or tags in a .CDX file.
>>>>
>>>>(2) You can extract a set of records using the SORT verb, with the same type of FOR statement. SORT will respect any filters set on the file at the moment. I see no advantage to this over a SQL Select, but whatever trips your trigger...
>>>>
>>>>(3) You can use a parameterized view to access the filtered subset of records; once you're using a parameterized view, you can index the view if necessary. If you set up the view properly, you can make changes to the view and update the table from the view.
>>>------
>>>Hi Ed and thanks for your reply....Can you give me a code
>>>sample on how I would use the SORT command?
>>
>
>Sorry for the formatting mess. This should read better...
>
>>Sure. It's right in the VFP docs, so you should probably RTFH!
>>
>>
USE JRandomTable
>>SORT TO SomeOtherRandomTable ;
>>   ON SomeNumFld /A, ;
>>      SomeChrFld /D, ;
>>      AnotherChr /AC
>>
>>This would create a table SomeOtherRandomTable.DBF containing all the fields in JRandomTable, sorted first by SomeNumFld in Ascending order, within any set of records that have the same value for SomeNumFld, the subset of records are sorted by SomeChrFld in Descending order, and then within any group have the samevalue for both SomeNumFld and SomeChrFld, the subset is sorted by AnotherChr in Ascending order in a case-insensitive manner. Example data:
>>
>>1,"Foo","Bar"
>>7,"Mumble","Bletch"
>>1,"FOO","banana"
>>1,"FOO","BAR"
>>1,"Mumble","Grr"
>>
>>would sort as:
>>
>>1,"Mumble","Grr"
>>1,"Foo","Bar"
>>1,"FOO","banana"
>>1,"FOO","BAR"
>>7,"Mumble","Bletch"
------
Thanks Ed for the code...
Robert Keith
Independent Developer
San Antonio, Texas
E-mail address:
rebelrob1@yahoo.com
Previous
Reply
Map
View

Click here to load this message in the networking platform