Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Set key
Message
De
21/09/1998 10:33:39
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00138717
Message ID:
00139038
Vues:
30
*Sample code
use exhiinfo
set order to showfk
set key to 6
?seek(3, 'exhiinfo', "Accnum") && fails
* Probably showfk=6 and accnum = 3 doesn't exist
* or accnum=3 is not the first occurance
locate for accnum=3 && showfk=6 and accnum=3

set order to accnum  && Also does implicit "set key to"
* this will locate a recordd that is outside the set key range
?seek(3, 'exhiinfo', "Accnum") && locate first occurance accnum=3

set key to && Already done implicitly

set filter to showfk = 6
locate
?seek(3, 'exhiinfo', "Accnum") && this works
* except SQL all commands respect to filter
Because seek looks for first occurance and should be able to move rec pointer as well.
Cetin

>Cetin,
>
>Your example works exactly as I would have expected. My application whould be performing in the same manner. When I set key to 6 and seek as in my example I should find the record that is there with that key. I am not sure why it would fail. Doesn't seem like it should. I am going to go back and validate the databse, reindex and see it the results change. As I do this rather often I don't think they will but it is worth a shot.
>
>Have you or anyone selse seen seek( x, file, tag) fail while set key is in place before?
>
>
>>"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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform