- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Null also remains after deleting everthing that is less than or equal to the maximum. So in one case, null acts as though it is less than every value while in the other it acts as though it is greater than them. This brings us back to the fact that null is outside of the set of values and therefore cannot be less than, equal to or greater than any value.
For obvious practical reasons, when you select data from a database that contains null values, the records have to go somewhere and, for lack of a better place, are sorted to be as though they are at the bottom of the range of values.
Admin
Of course not, 42 is the value of True
Admin
Careful? Seems a bit cavalier to me. This assumes the table 'HashIndex' indeed exists, and has the field named 'ItemHash'.
Admin
Of course real databases like Oracle allow you to specify how to sort the NULLs in your order by clause
ORDER BY [fields] NULLS FIRST/LAST
Admin
Hahah, nothing is about equal to negative pi?
Admin
No no no !!! We all know that 42 is the answer to Life the Universe and Everything. By deduction null should then be !(42).
Admin
This is obviously sub-optimal. The cursor should have been defined as
define cursor @table_del select id from table where id in (select id from table) or id is null
sheesh...!
Admin
Pshaw!
In my violent past, we expressed bytes by lining up our enemies and shooting the ones that were zeroes. Can you imagine the bloodbath when we tried to express 1 in a long double?
Admin
FIRST [:D]
[+o(]
Admin
Makes a lot of sense if you aren't sure that the table already has the required format.
Admin
No way, then you'd lose the indexes.
On that note, you can't TRUNCATE TABLE a table that references another table, at least in SQL Server.
If the programmer was really concerned about the mandatory WHERE clause, why not do a WHERE 1 = 1?
Admin
Suppose he wanted to delete nothing:
Admin
<FONT face="Courier New" size=2>"suposse".</FONT>
Admin
Slashdot is the biggest repository of tech retardation on the Web, so no, I do not count myself among the anti-M$ morons that blabber endlessly on slashdot.
Admin
So what's wrong with making null count as if it is less than the minimum value and not more than the maximum value? and at the very least it should equal itself. The whole null thing is so counterintuitive.
In databases: null = null, null > null, null < null, null != null, null <> null all return false
In Java, null == null returns true but float.NaN == float.NaN returns false, and I cannot remember what happens if float.NaN != float.NaN gives the same result as float.NaN < float.NaN || float.NaN > float.NaN. The idea that < or > is different from != boggles the mind.
Admin
The confusion comes in taking null to be an object in and of itself. Null is not an object, but more like a state. A value can be null (in a null state), but cannot be null (an object). Consider that null basically means "an undefined value" or "the absence of a known value". If we replace the word "null" with its definition then the equations make a little more sense:
null == null: translates to "an undefined value equals some other undefined value": result: indeterminate
null > null: translates to "an undefined value is greater than some other undefined value": result: indeterminate
...etc.
Take the case of null == null. What we are evaluating is whether the value on the left side of the equation equals the value on the right. What is the value on the left? We don't know (that's what null means, "an undefined value" or "the absence of a known value"). What is the value on the right? We don't know. Are they equal? We don't know.
As far as <> being different than !=, they are indeed different. The <> implies order, but some objects have no order. For example, the rational, real numbers have order:
1,2,3,4,5...
but the complex numbers do not:
1 + 2i is not necessarily greater than 1 + 1i since there are two axis of direction (the real number plane and the imaginary number plane). Likewise 2 + 1i is not necessarily greater than 1 + 1i. So when dealing with objects that have no order, greater than or less than have no meaning.
Admin
Probably was a novice SQL programmer who didn't know that you don't need a WHERE clause with the DELETE statement. [pi]
Admin
Admin
Sissy. They gave you a stick. We used our bare fingers.
Admin
But if greater and less DO have meaning, surely they should correspond to the definition of not equals. In SQL queries, where not (a = b) does not mean the same as where (a <> b) even though < and > have meaning. This constitutes absolute rubbish.
Admin
The point that I was making earlier is that, while <> usually can be used synonymously with "not equal", they are not fundamentally the same. You are correct that if objects have order than object a cannot be both less than or greater than b and yet also equal to b. Can you give a specific SQL example for values a and b where this takes place? Note that any example that includes null for a or b does not qualify as null has no order.
Admin
Given a suitable filter setting, Slashdot has a better signal to noise ratio than this forum (great jokes and puns notwithstanding). But if you think Microsoft is renowned for well-tested software and uses exemplary business practices, Slashdot probably isn't the place for you anyway.
Admin
Only if ANSI_NULLS is on
Admin
Interesting, but I would argue that NULL is more akin to "Is Not", perhaps better stated as "Absence of being", "Un-Being", or maybe you like "Opposite of existance". NULL is everything that never was and that will never be. I like to think of it as just plain "nothing", some students of philosophy may recognize this as a "No-Thing", or, a "Thing That Is Not".
So in the case of:
NULL == NULL
We are simply asking if nothing is the same as nothing, which is logically true. In this case, NULL itself is actually quite well defined. Using NULL as a specifier of an undefined value is a misuse of NULL, languages should have a construct to test and specify whether a value has been defined or not, as not being defined is a distinct and separate state from being defined as NULL. Consider preprocessor directives:
#define VALUE
VALUE is defined as nothing, nada, not a thing, otherwise affectionately known as NULL. VALUE "Is Not", it is a "No Thing". However:
#if defined(VALUE)
or if you prefer:
#ifdef VALUE
Is true.
For the other operations then, we can logically conclude that:
(NULL > NULL) = FALSE, (NULL < NULL) = FALSE, and (NULL != NULL) = FALSE. NULL and NULL are the same thing, one cannot be greater than the other.
Ordering NULL of course makes no sense, because ordering is an operation one applies on things, and NULL is already clearly defined as a "No-Thing". Nothing can be in order, but one cannot perform an ordering on nothing, as said action would itself be nothing and thusly nullified. (How can nothing be in order, the astute in the audience now question? Nothing is obviously in order with itself, but cannot be ordered against things which are, because ordering is an operation performed by definition solely on things which be. If you prefer, Being and Nothingness are distinct elements which cannot be ordered against each other, but Nothingness can be ordered against itself, but this is mostly a fruitless action as there are no other things with which to order it by).
If you put a gun to my head and forced me to order NULL into the sequence:
-3, -2, -1, 0, 1, 2, 3
I would order thusly:
-3, -2, -1, [0|NULL], 1, 2, 3
As "0", a concept of "None", is inherently cohesive with "Not Being". I would then walk away from you, crazy person with the gun, and not feel too badly about myself.
In many C programs, one can discern the author's confusion between "A Defined Object" and "Nothing" plainly whenever you see code like:
char *getValue(void *fromSomething)
{
char *resultOf = someOtherFunction(fromSomething);
if (!resultOf)
return strPut(""); // ick
else
return resultOf;
}
Unless you are purposefully returning an empty string as a workaround to some flawed library you are using, this is wasteful and not required. One could simply:
char *getValue(void *fromSomething)
{
return someOtherFunction(fromSomething);
}
Obviously this is a contrived example. Let's put it in more real-world terms, where we are parsing an RFC822 message and getting back the value of a specific header:
char *headerValue(char *headerName)
{
return parseMessageToFindHeader(headerName);
}
(Of course, this isn't production code so don't read too much into it past the concept of returning NULL versus an empty string).
Given:
To: Bob
From: Joe
Subject: Hello
headerValue("To")
returns "Bob", as expected, and:
headerValue("Foo")
returns NULL. In terms of English, the "To" header value is "Bob", and there isn't a value of the "Foo" header, as it doesn't exist. In other words, the value of the non-existant "Foo" header isn't. Is Not. NULL.
And just because I'm on the subject:
strlen(NULL)
Is of course, 0. This string length of NULL is not undefined, and should not return undefined (or worse, die!). If you're a skeptic, fear not, I'll guide you along.
NULL as previously mentioned is very clearly defined as "No-Thing" or "Not-a-thing", so the real world translation of this (the string length of nothing) is quite easy to conceptualize. In whatever room you happen to currently be sitting, carefully look around and count the number of live adult dinosaurs contained in the room where you are. Unless you happen to have developed some sort of time traveling device or discovered how to grow dinosaurs on your own, the answer is likely: 0. How did you derive this answer? You carefully scanned every nook and corner of the room, and determined that there was a total lack of existing dinosaurs in the room. That is, all of the dinosaurs in the room weren't. They all were not. The dinosaurs in the room were completely in a state of non-being. When you count the array of dinosaurs in the room (Nothing), you discover that there are exactly 0 dinosaurs. Just as we were looking for "the string length of nothing", we were now looking for "the head count of no dinosaurs". Said more simply:
count(lookForDinosaurs()) = 0;
We've established that in our search for dinosaurs we didn't discover any, so there are no dinosaurs in our room, or, all the dinosaurs in our room don't exist, so the lookForDinosaurs action we engaged in gave us back exactly Nothing. ("I looked for dinosaurs in my room and came up with nothing"). So we can restate:
count(Nothing) = 0;
Nothing, the No-Thing, Not-A-Thing, a.k.a. NULL. Now we're at:
count(NULL) = 0;
strlen is a type of counting action. It's not a great leap to arrive at:
strlen(NULL) = 0;
Ok, I'm done. That, or, the rest of this post is NULL, however you'd like to think of it.
Admin
What you have to keep in mind here is that we are not talking about a philosophical idea of what null means, but are instead referring to its specific definition as regards to database technology. Here is the first paragrah from the Microsoft SQL Server documentation regarding null values, which says exactly the opposite of what you just said:
"A value of NULL indicates the value is unknown. A value of NULL is different from an empty or zero value. No two null values are equal. Comparisons between two null values, or between a NULL and any other value, return unknown because the value of each NULL is unknown."
Wikipedia (for what it's worth) says,
"Columns in Relational database management systems (RDBMS) can optionally store NULL values. The presence of a NULL value indicates that the actual value of the column is unknown or not applicable.
In most RDMBSs, the result of testing NULL = NULL is FALSE. This is because one unknown value might not be equal to another unknown value".
As per the explanation found in my previous posts and the documentation given above, evaluating "null == null" returns an undefined (null) result.
If this is true, then most all major databases misuse null. Again, see the documentation posted above in response to your first paragrah.
"VALUE" itself is a varaible, which is defined. The value of "VALUE" (confusing, I know) is null as it has not been defined.
The reason that null is not greater than or less than another null is not because they are the same, but rather because you cannot order an undefined value.
Again, what we are talking about here are definite mathematical concepts, not philosophical ideas. We refer to the mathematical concept of order. Some sets simply have no order, such as the complex numbers pointed out in my previous post.
... -3, -2, -1, [0|Undefined], 1, 2, 3 ...
This makes no sense. Some things simply cannot be ordered.
Implementation of null outside of databases, as you show here, can sometimes get a little murky and is often used differently than null is used by databases. This is outside of the scope of the discussion.
Actually, strlen returns the length of a null terminated string, excluding the null terminator. In this case, the function encounters null immediately and returns zero.
I agree, the rest of this post has definitely yet to be defined.