Re: Insert/select union bug

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Peter <peter(at)greatnowhere(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Insert/select union bug
Date: 2006-09-27 09:57:54
Message-ID: 20060927095754.GA13693@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Sep 27, 2006 at 12:14:44PM +0300, Peter wrote:
> create table temp(a timestamptz);
>
> insert into temp(a) select NULL; /* this passes */
>
> insert into temp(a) select NULL union select NULL; /* fails:
> ERROR: column "a" is of type timestamp with time zone but expression is
> of type text
> */

Perhaps you could indicate in the subselects the type? For example:

insert into temp(a) select NULL::timestamptz union select NULL;

I think as long as the first has the right type, you're set.

BTW, UNION ALL is probably more efficient.

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Peter 2006-09-27 10:05:56 Re: Insert/select union bug
Previous Message Peter 2006-09-27 09:14:44 Insert/select union bug