Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
0, .NULL., EMPTY() numeric field
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00221542
Message ID:
00221571
Vues:
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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform