Re: syntax pb

2023-05-30 Thread Marc Millas
Thanks for the explanation. Crystal clear, thanks Marc MILLAS Senior Architect +33607850334 www.mokadb.com On Tue, May 30, 2023 at 7:31 PM Tom Lane wrote: > "David G. Johnston" writes: > > On Tue, May 30, 2023 at 8:53 AM Marc Millas > wrote > >> Too my understanding it looks like the parser

Re: syntax pb

2023-05-30 Thread Marc Millas
Marc MILLAS Senior Architect +33607850334 www.mokadb.com On Tue, May 30, 2023 at 7:12 PM David G. Johnston < david.g.johns...@gmail.com> wrote: > On Tue, May 30, 2023 at 8:53 AM Marc Millas wrote > > >> This comes from a prod environment and even casting NULLs (which is more >> than strange, B

Re: syntax pb

2023-05-30 Thread Marc Millas
Marc MILLAS Senior Architect +33607850334 www.mokadb.com On Tue, May 30, 2023 at 3:51 PM David G. Johnston < david.g.johns...@gmail.com> wrote: > On Tuesday, May 30, 2023, Marc Millas wrote: > >> >> I get: >> ERROR: column "d" is of type numeric but expression is of type text >> LINE 2: Selec

Re: syntax pb

2023-05-30 Thread Adrian Klaver
On 5/30/23 8:53 AM, Marc Millas wrote: Thanks Adrian, but if the query becomes more complex, for example with a few joins more, then even casting doesn't work. This comes from a prod environment and even casting NULLs (which is more than strange, BTW) generates absurd errors. Too my underst

Re: syntax pb

2023-05-30 Thread Adrian Klaver
On 5/30/23 10:31 AM, Tom Lane wrote: "David G. Johnston" writes: On Tue, May 30, 2023 at 8:53 AM Marc Millas wrote Too my understanding it looks like the parser did not parse the select distinct as we think he does. The DISTINCT clause doesn't really come into play here at all, so if you t

Re: syntax pb

2023-05-30 Thread Tom Lane
"David G. Johnston" writes: > On Tue, May 30, 2023 at 8:53 AM Marc Millas wrote >> Too my understanding it looks like the parser did not parse the select >> distinct as we think he does. > The DISTINCT clause doesn't really come into play here at all, so if you > think it does you indeed have a

Re: syntax pb

2023-05-30 Thread David G. Johnston
On Tue, May 30, 2023 at 8:53 AM Marc Millas wrote > This comes from a prod environment and even casting NULLs (which is more > than strange, BTW) generates absurd errors. > If you want an input to be anything other than plain text (numbers partially exempted) you need to cast it. Sure, some li

Re: syntax pb

2023-05-30 Thread hubert depesz lubaczewski
On Tue, May 30, 2023 at 05:53:30PM +0200, Marc Millas wrote: > Thanks Adrian, but if the query becomes more complex, for example with a > few joins more, then even casting doesn't work. > This comes from a prod environment and even casting NULLs (which is more > than strange, BTW) generates absurd

Re: syntax pb

2023-05-30 Thread Marc Millas
The above should have been: > > Insert into t2 (a, b, c, d) > Select distinct test1.t, 'abc' as b, NULL::text, NULL::numeric > From t1 test1; > > > > > which results in: > > > > select * from t2; > > a| b | c | d > > +-+--+-- > > azerty | abc | NULL | NULL > > >

Re: syntax pb

2023-05-30 Thread Adrian Klaver
On 5/30/23 07:38, Adrian Klaver wrote: On 5/30/23 06:45, Marc Millas wrote: Hi, I always have had difficulties to understand syntax. So... If I have: create table t1 (t text); create table t2 (a text, b text, c test, d numeric); Is c supposed to be text? Or are you indeed referring to some u

Re: syntax pb

2023-05-30 Thread Adrian Klaver
On 5/30/23 06:45, Marc Millas wrote: Hi, I always have had difficulties to understand syntax. So... If I have: create table t1 (t text); create table t2 (a text, b text, c test, d numeric); Is c supposed to be text? Or are you indeed referring to some unspecified type? insert into t1('azert

Re: syntax pb

2023-05-30 Thread Ray O'Donnell
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' a

Re: syntax pb

2023-05-30 Thread David G. Johnston
On Tuesday, May 30, 2023, Marc Millas 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 hi