Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
INDEXSEEK Bug?
Message
From
11/05/2002 11:03:41
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
11/05/2002 10:35:56
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00654373
Message ID:
00655381
Views:
61
>>Ray,
>>Couldn't follow the whole thread but maybe not told yet :)
>>We discussed this sometime ago. Indexseek() works on a buffered table BUT only returns .T. for a newly inserted row key as you move off the record. Whatever the type of buffering is (table or row) as soon as you move off the record indexseek() returns .t. Documentation is vague but I always got its purpose was this and not considered as a bug.
>>As you move off the record even if the buffering is at table level you get Indexseek() .t. for that record. I think it's exactly what I would want indexseek() to do for me.
>>Cetin
>
>
>Well, thanks very much, Cetin, that finaly sheds some light on the subject.
>
>If you take my original code sample and modify the first INSERT block as follows:
>
>
>FOR n = 1 TO 10
>   INSERT INTO anytable (pkey,cchar) VALUES (n,'string')
>   SKIP
>
>   IF !INDEXSEEK(n,.F.,'anytable','pkey') 
&& same result with .T. or .F. in move record pointer parameter
>      WAIT TRANSFORM(n) WINDOW && no record found ???? Why not?
>   ENDIF
>ENDFOR
>
>
>INDEXSEEK returns .T., as expected.
>
>Howerver, Cetin, I can't agree that this isn't a bug. If you look at my original sample code, you'll see that SEEK and KEYMATCH behave as expected in all cases. There's no reason I can see that INDEXSEEK should behave differently. In fact, if I want to determine if a key value exists without moving the record pointer---the real intent of INDEXSEEK---it is the only way I can do it. And I sure as heck want it to work in all cases, whether I happen to be on that record at the time, or not.

Ray,
Why I don't accept it as a bug but exactly the intended behaviour (at least personally:) :

Say I'm inserting new 'location' names, it might or not be a PK.
I want a location appear only once (maybe just for this time - say for adding the ones that has no entries yet).

I enter 'my location' on a row. I care its existence only and only if exists on another row. Do an indexseek(), get .f. and let the pointer move off the record. If it returned .t. I had to check if the founded record was the record I already inserted or not (and I did that in past thinking why I can't do that in an easier way).
When I move off the record and do an indexseek() for 'my location' it would return .t. and I wouldn't let the record with that value.
However there is still a problem ;
I'm doing inserts w/o moving off the record at all and might end up by inserting multiple 'my location'.
It's easily workaroundable :
if !indexseek(...) and mytable.myfield # 'my location'
This would behave as seek() except it wouldn't move the pointer.
Cetin
Ç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