Re: syntax pb

From: Ray O'Donnell <ray(at)rodonnell(dot)ie>
To: Marc Millas <marc(dot)millas(at)mokadb(dot)com>, "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: syntax pb
Date: 2023-05-30 13:51:34
Message-ID: ec91c3fc-9943-0ba1-e7f8-05c966de1102@rodonnell.ie
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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(at)rodonnell(dot)ie

In response to

  • syntax pb at 2023-05-30 13:45:11 from Marc Millas

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2023-05-30 14:38:15 Re: syntax pb
Previous Message David G. Johnston 2023-05-30 13:51:09 Re: syntax pb