Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why I cannot search a NULL value ? BUG ?
Message
 
 
To
30/08/2003 16:34:34
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00824792
Message ID:
00824881
Views:
17
Fabio,

>On SQL Server, if i SET ANSI_NULLS OFF, NULL is a defined value,

This explains a lot of your misunderstanding about how nulls work.

VFP behaves exactly like SQL Server with SET ANSI_NULLS ON. We have a couple of hundred SQL server databases in use at our company and they all use SET ANSI_NULLS ON.

Quoting from the SQL Server BOL topic http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_set-set_9rec.asp , bold emphasis is mine:

When SET ANSI_NULLS is OFF, the Equals (=) and Not Equal To (< >) comparison operators do not follow the SQL-92 standard. A SELECT statement using WHERE column_name = NULL returns the rows with null values in column_name. A SELECT statement using WHERE column_name < > NULL returns the rows with nonnull values in the column. In addition, a SELECT statement using WHERE column_name < > XYZ_value returns all rows that are not XYZ value and that are not NULL.

The plain facts are in VFP, that you must use isnull() to test for a null value, you are free to ignore this all you want, but it's your error, not an error in the way VFP handles hulls.

>you comment LOCATE like i dont understand A=NULL,

You clearly don't understand it. Quoting the VFP help:

LOCATE [FOR lExpression1]

lExpression = a logical expression

A = NULL must evaluate to NULL. NULL is neither true or false, NULL is unknown, indeterminate

isnull( a ) evaluates to a .t. or .f. depending on whether or not the value in the field A is null or not. Using isull() in your code is not a workaround at all.
llNull = .f. && make each memvar the correct type for the following expressions to work
lnNull = 0
lcNull = ""

llNull = .null. && set their values to null
lnNull = .null.
lcNull = .null.

? .t. and llNull
? llNull = .null.
? 1 + lnNull
? "abc" + lcNull
The 4 print statements all return the correct value, they all print NULL. Your LOCATE FOR A = .NULL. is an example of what happens in the second ? line above.

>Because if a MVP defend a VFP insufficient behaviour, VFPT have they find motivations in order not to improve the product.

There is no need for the VFP team to change anything about its null model, it works exactly like it should. I am defending its currently correct behavior.
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform