Discussion:
NULL Data Type Bugs
(too old to reply)
Rod Pope
2008-09-16 23:48:35 UTC
Permalink
The company I'm consulting for has a large number of applications currently running under dBPlus 2.61.5. The comments below on bugs with NULL fields come from several errors in multiple apps.


from page 4 of the dBL Language Reference

String data
. . . A string with no characters is called an empty string or a null string (not to be confused with the null data type).

Questions: Is a character field in a table where no data has ever been entered a null string or a null data type? Why does the entire string in a concatenation operation ("anything" ± variable) become a null string if the variable is null? An undefined character type field or other type converted to string for concatenation should be a null string, NOT a null data type which follows the Note for the plus operator below.



from page 4 of the dBL Language Reference

Logical data
A logical, or boolean, value can be only one of three things: true, false or null. These logical values are expressed literally in dBL by the keywords true, false and null.

Question: When doing a REPLACE operation of a logical field to a new record in one table with data from a logical field in another table, what value should be in the "to" field when the "from" field is null?

In my current application, the answer is "TRUE" That is a bug!


from page 5 of the dBL Language Reference

A null value is different from a blank or zero value; null is the absence of a value.
A null value in a field would indicate that no data has been entered into the field, like in a new row, or that the field has been emptied on purpose. In certain summary operations, null fields are ignored. For example, if you are averaging a numeric field, rows with a null value in the field are ignored. If instead a null value was considered to be zero or some other value, it would affect the average.

Questions: What operation is used to "empty on purpose"? What are the other "summary operations"?



from page 21 of the dBL Language Reference

+ (“plus”) operator
Addition, concatenation, unary positive operator.
.
.
.
Note Adding the value null to anything (or anything to null) results in the value null.

Question: Why is this note true? Recently we added a new part to our parts database with a zero cost (giveaways at shows). The data entry clerk skipped the "Price per Unit" field during data entry, leaving it undefined (null). When the invoice was created, the total was $0.00 (numeric formatted nulls print as zero). Why is the global default for a numeric not zero?
Geoff Wass [dBVIPS]
2008-09-17 05:14:19 UTC
Permalink
Post by Rod Pope
The company I'm consulting for has a large number of applications currently running under dBPlus 2.61.5. The comments below on bugs with NULL fields come from several errors in multiple apps.
from page 4 of the dBL Language Reference
String data
. . . A string with no characters is called an empty string or a null string (not to be confused with the null data type).
Questions: Is a character field in a table where no data has ever been entered a null string or a null data type? Why does the entire string in a concatenation operation ("anything" ± variable) become a null string if the
variable is null? An undefined character type field or other type converted to string for concatenation should be a null string, NOT a null data type which follows the Note for the plus operator below.

In a level 7 table or SQL database character fields start off as null
unless you takes steps to establish an alternative default.
Post by Rod Pope
from page 4 of the dBL Language Reference
Logical data
A logical, or boolean, value can be only one of three things: true, false or null. These logical values are expressed literally in dBL by the keywords true, false and null.
Question: When doing a REPLACE operation of a logical field to a new record in one table with data from a logical field in another table, what value should be in the "to" field when the "from" field is null?
In my current application, the answer is "TRUE" That is a bug!
What type of table do you have? It only applies to Level 7 tables.
Post by Rod Pope
from page 5 of the dBL Language Reference
A null value is different from a blank or zero value; null is the absence of a value.
A null value in a field would indicate that no data has been entered into the field, like in a new row, or that the field has been emptied on purpose. In certain summary operations, null fields are ignored. For example, if you
are averaging a numeric field, rows with a null value in the field are ignored. If instead a null value was considered to be zero or some other value, it would affect the average.
Post by Rod Pope
Questions: What operation is used to "empty on purpose"? What are the other "summary operations"?
Depending on what you mean, NULL can be empty on purpose (ie. it is not
true and it is not false).

The summary functions are sum, minimum, maximum, count, average,
standard deviation, variance. You can see more under the CALCULATE
command.
Post by Rod Pope
from page 21 of the dBL Language Reference
+ (?plus?) operator
Addition, concatenation, unary positive operator.
.
.
.
Note Adding the value null to anything (or anything to null) results in the value null.
Question: Why is this note true? Recently we added a new part to our parts database with a zero cost (giveaways at shows). The data entry clerk skipped the "Price per Unit" field during data entry, leaving it undefined (null).
When the invoice was created, the total was $0.00 (numeric formatted nulls print as zero). Why is the global default for a numeric not zero?

It is true. The visual representation of the null may be 0, but the
anything+null=null rule still holds.

The default is null and not zero in order to be consistent.

All this behaviour is quite normal in dBASE PLUS and other languages. It
takes a while to get used to NULLs, but once you do they become very
useful tools.
--
Geoff Wass [dBVIPS]
Montréal, Québec, Canada

.|.|.| dBASE info at http://geocities.com/geoff_wass |.|.|.
.|.|.| ---------------------------------------------------------- |.|.|.
.|.|.| IT Consultant http://Geoff_Wass.com |.|.|.
Glenn Johansen
2008-09-17 01:59:01 UTC
Permalink
"ANYTHING" + null = null

see the setautonullfields in the OLH and turn it off
Be warned though it does not work with xdml "append from" command.
You will have to scan your current tables and get rid of any null's.

Let me know if that is what you want, I have a routine to do it.

- glenn
Post by Rod Pope
The company I'm consulting for has a large number of applications
currently running under dBPlus 2.61.5. The comments below on bugs with
NULL fields come from several errors in multiple apps.
from page 4 of the dBL Language Reference
String data
. . . A string with no characters is called an empty string or a null
string (not to be confused with the null data type).
Questions: Is a character field in a table where no data has ever been
entered a null string or a null data type? Why does the entire string in
a concatenation operation ("anything" ± variable) become a null string if
the variable is null? An undefined character type field or other type
converted to string for concatenation should be a null string, NOT a null
data type which follows the Note for the plus operator below.
from page 4 of the dBL Language Reference
Logical data
A logical, or boolean, value can be only one of three things: true, false
or null. These logical values are expressed literally in dBL by the
keywords true, false and null.
Question: When doing a REPLACE operation of a logical field to a new
record in one table with data from a logical field in another table, what
value should be in the "to" field when the "from" field is null?
In my current application, the answer is "TRUE" That is a bug!
from page 5 of the dBL Language Reference
A null value is different from a blank or zero value; null is the absence of a value.
A null value in a field would indicate that no data has been entered into
the field, like in a new row, or that the field has been emptied on
purpose. In certain summary operations, null fields are ignored. For
example, if you are averaging a numeric field, rows with a null value in
the field are ignored. If instead a null value was considered to be zero
or some other value, it would affect the average.
Questions: What operation is used to "empty on purpose"? What are the
other "summary operations"?
from page 21 of the dBL Language Reference
+ ("plus") operator
Addition, concatenation, unary positive operator.
.
.
.
Note Adding the value null to anything (or anything to null) results in
the value null.
Question: Why is this note true? Recently we added a new part to our
parts database with a zero cost (giveaways at shows). The data entry
clerk skipped the "Price per Unit" field during data entry, leaving it
undefined (null). When the invoice was created, the total was $0.00
(numeric formatted nulls print as zero). Why is the global default for a
numeric not zero?
Lysander
2008-09-17 07:44:32 UTC
Permalink
Post by Rod Pope
The company I'm consulting for has a large number of applications currently running under dBPlus 2.61.5. The comments below on bugs with NULL fields come from several errors in multiple apps.
Rod,
all of what you are posting are not bugs.

As Geoff pointed out, make sure you are using the table format matching
the manual/language reference.


Ever again people have problems in understanding a NULL value, but NULL
values are very very important and it was a blessing that dBase
introduced them with 32-Bit and table level 7.

Peoples understanding of the matter usually brightens up when you tell
them "imagine NULL as 'unknown'".

5 apples + 3 apples + an unknown number of apples = .....
... an unknown number of apples...
Eric Logan
2008-09-17 17:39:38 UTC
Permalink
This post might be inappropriate. Click to display it.
Loading...