Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
0, .NULL., EMPTY() numeric field
Message
From
21/05/1999 15:44:11
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00221542
Message ID:
00221577
Views:
13
>>>I have a numeric field with no default value that allows .NULL. values. The users say that "blank", as they would call it, means "undefined", which is why I allow null. I noticed that if you delete the number in the text box, it fills in a 0. I gather that blank and 0 are the same thing in a numeric field, and that EMPTY(numericfield) returns .T. if it's a 0. If the record is saved without anything being typed in that field, you don't see a 0 on the form or in a browse window, but it seems to get treated as a 0 by vfp functions, and ISNULL() returns .F.. Am I correct that the 0 and the apparently blank entry are really the same thing even if they don't look like it? Is there any function that can distinguish them?
>>>
>>>I gave the users a button that enters .NULL. in the field so they wouldn't have to type that in the box. That seems like a kludge. Is there a better or more standard way to facilitate null entries in numeric textboxes?
>>
>>0 and apparently blank are not same if one is initialized to null. If nulls aren't allowed they would be same. Sometimes this catches you in a control :
>>if oldval(..) = curval(..) && Oldval is null for a new record
>>&& Or an explicit "insert into ... values (.null. , ...) might be executed
>>&& and nulldisplay = ""
>>By default "nulls" setting insert nonnull (empty) values.
>>Cetin
>
>I did a test query to make sure of this. Nulls are allowed, but the new records are not initialized to .NULL. or anything else (though perhaps they should be). Here are some typical results:
>
>quantity  EMPTY(quantity)  ISNULL(quantity)  quantity=0
>
>4         .F.              .F.               .F.
>.NULL.    .F.              .T.               .NULL.
>0         .T.              .F.               .T.
>(blank)   .T.              .F.               .T.
>
>
>The "blanks" seem to behave exactly like 0, but I don't see 0, and, more importantly, the users don't.
>
>That tidbit about using Ctrl-0 to input .NULL. was interesting. I didn't know it, and my users probably didn't either. It doesn't seem to work in Access, so I guess that it's not a Windows standard. I think I'll leave my "null input" button there until there is a better idea.

No it's not a windows standart but VFP. What about "set null" although it doesn't effect all commands (effects SQL commands).
ie:
set null on
insert into mytable (field1, field3) values (1,"blahbla")
would insert .null. to field2 (not included in insert list). Fields should be set to allow nulls.
I always use "insert-SQL" for new records so this works.
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