Re: union of types in a different category

From: James Harper <james(dot)harper(at)bendigoit(dot)com(dot)au>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: union of types in a different category
Date: 2014-02-23 03:40:08
Message-ID: 6035A0D088A63A46850C3988ED045A4B6F3B0219@BITCOM1.int.sbss.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> Did you try it?
>
> postgres=# SELECT '1' UNION SELECT 2;
> ?column?
> ----------
> 1
> 2
> (2 rows)
>
> Now, if I'd done this it would fail:
>
> postgres=# SELECT '1'::text UNION SELECT 2;
> ERROR: UNION types text and integer cannot be matched
> LINE 1: SELECT '1'::text UNION SELECT 2;
> ^

I did try it, but probably only in the latter form through a query translator I'm working on, and also SELECT 'X' UNION SELECT 1, hoping that they would cast implicitly to a string.

Sorry for the confusion and thanks for the response!

James

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jov 2014-02-23 06:48:35 stand by is starting until I do some work in the primary
Previous Message Tom Lane 2014-02-23 03:33:39 Re: union of types in a different category