Skip site navigation (1) Skip section navigation (2)

Problem with select and null

From: "Frank Millman" <frank(at)chagford(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Problem with select and null
Date: 2004-08-30 10:15:01
Message-ID: 000801c48e7a$362bc910$0401a8c0@chagford.com (view raw or flat)
Thread:
Lists: pgsql-general
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.

Under some circumstances my program generates the above select statement, so this is not an academic question.

Platform is PostgreSQL 7.4.1, running on Redhat 9.

Is this a bug? Is there any workaround? My workaround for now is to 'coalesce' to zero all the values which could return null. The result is zero instead of null, which is not what I want, but I can live with it in the short term.

TIA for any suggestions.

Frank Millman

Responses

pgsql-general by date

Next:From: Clodoaldo Pinto NetoDate: 2004-08-30 10:27:35
Subject: Re: pg_restore: error returned by PQputline
Previous:From: Francois SuterDate: 2004-08-30 09:35:05
Subject: Technical recommendations

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group