Re: Nulls get converted to 0 problem

From: "scott(dot)marlowe" <scott(dot)marlowe(at)ihs(dot)com>
To: Jon Earle <je_pgsql(at)kronos(dot)honk(dot)org>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Nulls get converted to 0 problem
Date: 2003-06-06 14:45:47
Message-ID: Pine.LNX.4.33.0306060840270.19717-100000@css120.ihs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, 5 Jun 2003, 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?

Every interface I know of in every language (except cold fusion) has a
test for null. There IS a difference, and it's not a difference of just
semantics, it has real world meaning.

Enter a record for me. Enter my cell phone number. It's a text type. If
you enter a NULL you are saying I may or may not have a cell phone, you
don't know. If you enter '' you are saying that I do NOT have a cell
phone.

Hey, who has a cell phone we don't have numbers for?

select * from table where cell_phone IS NULL;

I don't have to make up a boolean to say what I mean when I put in a '' or
a NULL.

For numbers, a NULL should never be coerced to 0, which is what was
happening to Ari due to the older jdbc driver. Since blank numeric and
date types aren't allowed there's no confusion issue. But for text there
certainly is a difference in meaning.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Stephan Szabo 2003-06-06 14:47:34 Re: Create index on the year of a date column
Previous Message scott.marlowe 2003-06-06 14:38:59 Re: EXTERN JOIN with WHEN query