Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Set key
Message
From
21/09/1998 09:54:48
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00138717
Message ID:
00139009
Views:
32
"Set key" is a kind of filter on index. It limits access to part of index. If your seek() falls in that range of "set key" then seek() returns .t. (you limit seek to a range).
ie: home()+"samples\data\customer" has country and contact indexes.
set order to tag country
set key to "GERMANY" && Only upper(country) = "GERMANY" is accessible
?seek("Janine Labrune","customer","contacts") && .f.
set key to   && Remove limitation
?seek("Janine Labrune","customer","contacts") && .t.
If applicable set key seems much faster than filter.
Cetin

>>Is show fk a filtered or unique index?
>
>No. :)
>
>
>Showfk is a foreign key to the show table and is a regular VFP index, no filter, non-unique key.
>
>In my tables there are multiple records for each show. My current application uses SET FILTER to limit records to the currently selected show. I saw another message about SET KEY and thought that maybe this would be better for what I was doing. I played around with SET KEY and found the things that I outlined in my message.
>
>I guess I thought that I could use SET KEY as a replacement for SET FILTER. From what I discovered my assumption must have been wrong or I don't understand the proper use of SET KEY.
>
>
>>>I am playing around with set key vs set filter and ran across this. I set key then seek on a different tag and it fails. I set filter and seek and it works.
>>>
>>>*Sample code
>>>use exhiinfo
>>>set order to showfk
>>>set key to 6
>>>?seek(3, 'exhiinfo', "Accnum") && fails
>>>
>>>set order to accnum
>>>* this will locate a recordd that is outside the set key range
>>>?seek(3, 'exhiinfo', "Accnum")
>>>
>>>set key to
>>>
>>>set filter to showfk = 6
>>>locate
>>>?seek(3, 'exhiinfo', "Accnum") && this works
>>>
>>>Anybody seen this before. Am I using set key wrong?
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform