Re: Problem with select and null - Mailing list pgsql-general

From Michael Paesold
Subject Re: Problem with select and null
Date
Msg-id 012601c48eaa$f53ee1e0$ad01a8c0@zaphod
Whole thread Raw
In response to Problem with select and null  ("Frank Millman" <frank@chagford.com>)
List 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


pgsql-general by date:

Previous
From: Elie Nacache
Date:
Subject: Hebrew support -- please help !
Next
From: Tom Lane
Date:
Subject: Re: Problem with select and null