From: Ray O'Donnell <ray@rodonnell.ie>
To: Marc Millas <marc.millas@mokadb.com>
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: syntax pb
Date: Tue, 30 May 2023 14:51:34 +0100
Message-ID: <ec91c3fc-9943-0ba1-e7f8-05c966de1102@rodonnell.ie> (raw)
In-Reply-To: <CADX_1aZ5gMfoR+D7LpsQ2jq7N1AFcpVCh6TP1N0deZdqNaPPrg@mail.gmail.com>
References: <CADX_1aZ5gMfoR+D7LpsQ2jq7N1AFcpVCh6TP1N0deZdqNaPPrg@mail.gmail.com>
On 30/05/2023 14:45, Marc Millas wrote:
> and , now, if I want to insert that:
> Insert into t2 (a, b, c, d)
> Select distinct test1.t, 'abc' as b, NULL as c, NULL as d
> From t1 test1;
>
> I get:
> ERROR: column "d" is of type numeric but expression is of type text
> LINE 2: Select distinct test1.t, 'abc' as b, NULL as c, NULL as d
>
> HINT: You will need to rewrite or cast the expression.
I'm guessing you'll need to cast the NULLs:
.... select distinct test1.t, 'abc', null::text, null::numeric ...
I don't think you need the aliases.
Ray.
>
> Can someone give a short SQL syntax hint ?
>
> thanks,
>
>
>
> Marc MILLAS
> Senior Architect
> +33607850334
> www.mokadb.com <http://www.mokadb.com;
>
--
Raymond O'Donnell // Galway // Ireland
ray@rodonnell.ie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: ray@rodonnell.ie, marc.millas@mokadb.com
Subject: Re: syntax pb
In-Reply-To: <ec91c3fc-9943-0ba1-e7f8-05c966de1102@rodonnell.ie>
References: <CADX_1aZ5gMfoR+D7LpsQ2jq7N1AFcpVCh6TP1N0deZdqNaPPrg@mail.gmail.com> <ec91c3fc-9943-0ba1-e7f8-05c966de1102@rodonnell.ie>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox