Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Simple select that doesn't work..
Message
 
To
30/11/2006 18:37:03
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01173935
Message ID:
01174034
Views:
8
>Now I'm lost. :(
>
>Why is it that R, R1, R2 is selected when I do "select * from table where ckey="R".. ")
>
>???

As Cetin said SET ASNI controls this in SELECT statements and SET EXACT and the == operator control it in VFP code. Here are the rules for string comparison;

Default: (SET ANSI OFF and SET EXACT OFF) The string on the left is compared one char at a time with the string on the right until the string on the right is exhausted, then the result is returned.

SET ANSI ON (Effects SQL syntax): The shorter is padded with trailing spaces to be of equal length to the lgoner string and then they are compared as above.

SET EXACT ON (Effects VFP syntax): The shorter is padded with trailing spaces to be of equal length to the lgoner string and then they are compared as above.

The == operator: The string on the left is compared one char at a time with the string on the right until the string on the right is exhausted, then the two strings are compared for length and the result is returned.

SET ASNI and SET EXACT are NOT the same as using == as can be seen in the following;
lcStr1 = "John   "
lcStr2 = "John"

SET EXACT OFF
? lcStr1 = lcStr2 && .T.
? lcStr1 == lcStr2 && .F.

SET EXACT ON
?lcStr1 = lcStr2 && .T. once lcStr2 is padded with spaces they are equal
?lcSTr1 == lcStr2 && .F.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform