Re: Weird NULL behavior - Mailing list pgsql-sql

From Stephan Szabo
Subject Re: Weird NULL behavior
Date
Msg-id 20021107083423.A97075-100000@megazone23.bigpanda.com
Whole thread Raw
In response to Weird NULL behavior  (Ludwig Lim <lud_nowhere_man@yahoo.com>)
Responses Re: Weird NULL behavior  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-sql
On Thu, 7 Nov 2002, Ludwig Lim wrote:

> Hi:
>
>   Has anyone encountered this before?
>   SELECT CAST ( (NULL*NULL) AS NUMERIC(2,0));
>
>
>   returns the following error message:
>   Cannot cast type '"char"' to '"numeric"'

It seems to me that it's trying to decide on a type
for the expression NULL * NULL.  It's a NULL, but a
NULL of what type?  I think the spec gets around
this by disallowing such structures AFAIK (NULL
can be used in like row value constructors, case
and cast).  I think the "sql" way of doing the
above would be
select cast(cast(NULL as NUMERIC(2,0))*cast(NULL as NUMERIC(2,0))as NUMERIC(2,0));



pgsql-sql by date:

Previous
From: Jean-Luc Lachance
Date:
Subject: Re: Copying a rowtype variable.
Next
From: Achilleus Mantzios
Date:
Subject: Re: [GENERAL] Problem: Referential Integrity Constraints lost