Re: Nulls get converted to 0 problem

From: Andre Truter <andre(dot)truter(at)intekom(dot)co(dot)za>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Nulls get converted to 0 problem
Date: 2003-06-06 15:54:49
Message-ID: 1054914889.17932.178.camel@tux.atio.co.za
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, 2003-06-05 at 15:39, Jon Earle wrote:
> On Wed, 4 Jun 2003 terry(at)ashtonwoodshomes(dot)com wrote:
>
> > Oracle *incorrectly* interprets blank (empty) strings as NULL. They are NOT
> > the same. A string of zero characters is a string nonetheless. A NULL is
> > "the absence of value", which equals nothing (theoretically not even another
> > NULL).
>
> If you're testing a value, you're testing to see if there's something in
> there or not - what difference does it make if the variable contains 0, ""
> or NULL?
>
> Why not adhere to the practices inherent (and thus anticipated by
> developers) in other languages (C comes to mind) where 0, NULL and "" are
> equivalent?
>
> Cheers!

No! For me it is very important that NULL does not equal 0 or "",
because we have a database where a value of 0 means 0 and a NULL means
that the data normally stored there is not applicable for that record.
We calculate averages on the fields, and we don't want 'not applicable'
values to affect the average.

In any case, this is actually in line with languages like C, because
NULL means that no memory has been assigned to a variable, it does not
mean that the value stored in that variable is 0, or even "".

NULL, 0 and "" are definitely not the same thing in C. If you see them
as the same, you are just looking for segmentation faults. :-)

In any case, NULL should not equal 0, as 0 is a value (between -1 and
1), while NULL is nothing, you cannot compare it to another value.

Is NULL smaller or larger than 1?

--
Andre Truter
Software Engineer
Registered Linux user #185282
ICQ #40935899 AIM: trusoftzaf
http://www.trusoft.za.net

<------------------------------------------------->
< The box said: Requires Windows 95 or better... >
< So I installed Linux >
<------------------------------------------------->

Disclaimer and Confidentiality Warning

This message is intended for the addressee only. If you are not the intended recipient of this message, you are notified that any distribution, use of or copying of this communication is strictly prohibited. If you have received the communication in error, please notify the sender immediately. The views and opinions expressed in this message are those of the individual sender of this message and do not necessarily represent the views and opinions of ATIO. Consequently, ATIO does not accept responsibility for such views and opinions and this message should not be read as representing the views and opinions of ATIO without subsequent written confirmation. Each page attached hereto must also be read in conjunction with this disclaimer.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Joe Conway 2003-06-06 16:21:54 Re: Bug in metaphone (contrib/fuzzystrmatch)
Previous Message Bill.Allie 2003-06-06 15:36:59 Re: Approved