Re: Problem with select and null

From: "Michael Paesold" <mpaesold(at)gmx(dot)at>
To: "Frank Millman" <frank(at)chagford(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Problem with select and null
Date: 2004-08-30 16:03:52
Message-ID: 012601c48eaa$f53ee1e0$ad01a8c0@zaphod
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Frank Millman wrote:

> Hi all
>
> 'SELECT (null * null)' returns null
>
> 'SELECT (null - 0)' returns null
>
> 'SELECT ((null * null) - 0)' gives the following error -
> ERROR: operator does not exist: "char" - integer
>
> Why does this statement give an error? I would expect it to return null.

This does not seem to be a bug from my point of view. Postgres just doesn't
know what datatype these nulls should be. You can cast the null values to
integer (or float if you need):

SELECT ((null::integer * null::integer) - 0);
-- returns null

Best Regards,
Michael Paesold

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2004-08-30 16:17:16 Re: Problem with select and null
Previous Message Elie Nacache 2004-08-30 15:43:31 Hebrew support -- please help !