Re: syntax pb

From: Marc Millas <marc(dot)millas(at)mokadb(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: syntax pb
Date: 2023-05-30 18:28:18
Message-ID: CADX_1aZCCyHinjZC_W3J3YLNFsFxMW74isxf9WtEYhuCfOhG8Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Marc MILLAS
Senior Architect
+33607850334
www.mokadb.com

On Tue, May 30, 2023 at 3:51 PM David G. Johnston <
david(dot)g(dot)johnston(at)gmail(dot)com> wrote:

> On Tuesday, May 30, 2023, Marc Millas <marc(dot)millas(at)mokadb(dot)com> wrote:
>
>>
>> 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.
>>
>> Can someone give a short SQL syntax hint ?
>>
>
>
> https://www.postgresql.org/docs/current/sql-expressions.html#SQL-SYNTAX-TYPE-CASTS
>

I plainly agree on that...
but its NOT what's happeninng. The doc you point to states:
"An explicit type cast can usually be omitted if there is no ambiguity as
to the type that a value expression must produce (for example, when it is
assigned to a table column);"

in the SQL I provide I ask to put a NULL in a numeric column.
Can you tell where the ambiguity is ?

>
> David J.
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Marc Millas 2023-05-30 18:31:12 Re: syntax pb
Previous Message Adrian Klaver 2023-05-30 17:59:26 Re: syntax pb