Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B56194771A9 for ; Thu, 7 Nov 2002 11:43:14 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 415334761A1 for ; Thu, 7 Nov 2002 11:41:29 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 16E5DD613; Thu, 7 Nov 2002 08:41:26 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 0C6945C04; Thu, 7 Nov 2002 08:41:26 -0800 (PST) Date: Thu, 7 Nov 2002 08:41:26 -0800 (PST) From: Stephan Szabo To: Ludwig Lim Cc: PostgreSQL Mailing List Subject: Re: Weird NULL behavior In-Reply-To: <20021107114103.43007.qmail@web80306.mail.yahoo.com> Message-ID: <20021107083423.A97075-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/111 X-Sequence-Number: 10253 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));