Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Strange SEEK
Message
 
 
To
14/03/2009 13:43:34
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01388076
Message ID:
01388099
Views:
44
It's leftover from dark days of Dbase II/FoxBase when FoxPro tried to be "helpful" instead of generating an error.
As long as index is numeric, FoxPro Will try to convert a string argument into a number and seek on it.
CREATE CURSOR zzz (dd n(5))
FOR i=0 TO 10
	INSERT INTO zzz (dd) VALUES (i)
NEXT
INDEX on dd TO zzzi
? SEEK("A")
>Why does it work ?
>
>CREATE CURSOR zzz (dd n(5))
>FOR i=1 TO 10
> INSERT INTO zzz (dd) VALUES (i)
>NEXT
>INDEX on dd TO zzzi
>SEEK 2
>? FOUND() && .t.
>SEEK "2 anything else"
>? FOUND() && .t.
>SEEK "2.0"
>? FOUND() && .t.
>USE IN zzz
>RETURN
>
>Search is successful in all cases. Though index is created on numeric field, search is done with character expression.
>It MUST show a message about datatype mismatch. If not, it's terrible to change/define data types of searched
>field or searched expression "on-the-fly".
>SET ANSI, SET EXACT doesn't matter.
>VFP9+SP2.
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform