Re: why the need for is null?

From: Guy Fraser <guy(at)incentre(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: why the need for is null?
Date: 2004-01-02 18:39:47
Message-ID: 3FF5BAF3.1030405@incentre.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Baldur Norddahl wrote:

> Quoting Martijn van Oosterhout <kleptog(at)svana(dot)org>:
>
...

>>You could create a new operator, but that means you'll have difficulty
>>moving it to any database that doesn't have that operator (which is most of
>>them).
>>
>>
>
>Any commercial database vendor would be happy to make such a feature just for
>that reason: to lock me in to their database :-). I do not try to stay database
>neutral, and use lots of other features that will only work in postgresql.
>
>
There already is an operator, and it is the ANSI SQL operator "IS". Just
because "IS" does not use puctuation characters does not mean it is not
an operator.

>>If you want it to match perhaps you should forget NULL and use '' (zero
>>length string) instead.
>>
>>
An empty string is an empty string, and a NULL is the lack of there being a string, they are not the same. If you want to emulate what you have proposed then use the function "coalesce".

Example:

select coalesce(string_column,'') from some_table ;

This will return an empty string for all records that have no data in
string_column.

I have designed a number of realtime data collection programs, and when inserting only the available data into the proper columns of the table, I often end up will "NULL" columns because there was no data for that column. It is very usefull to know if you had data available or if the data was 0 or an empty string.

If you still don't understand, then use MySQL it is messed up and allows weird things like most of what you want to do.

Happy New Year

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Luis Neves 2004-01-02 19:07:43 Foodmart2000 sample database
Previous Message Bruce Momjian 2004-01-02 18:09:07 postgresql.org server problems