syntax pb - Mailing list pgsql-general

From Marc Millas
Subject syntax pb
Date
Msg-id CADX_1aZ5gMfoR+D7LpsQ2jq7N1AFcpVCh6TP1N0deZdqNaPPrg@mail.gmail.com
Whole thread Raw
Responses Re: syntax pb  ("David G. Johnston" <david.g.johnston@gmail.com>)
Re: syntax pb  (Ray O'Donnell <ray@rodonnell.ie>)
Re: syntax pb  (Adrian Klaver <adrian.klaver@aklaver.com>)
List pgsql-general
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);
insert into t1('azerty');
INSERT 0 1
fine !


so, now, if I write:
Select distinct test1.t, 'abc' as b, NULL as c, NULL as d 
From t1 test1;
   t      |  b   | c  | d
--------+-----+---+---
 azerty | abc |   |
(1 row)

ok.

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.

Can someone give a short SQL syntax hint ?

thanks,



Marc MILLAS
Senior Architect
+33607850334

pgsql-general by date:

Previous
From: Laurenz Albe
Date:
Subject: Re: Where I can find the achieve of the 'generate_series' ?
Next
From: "David G. Johnston"
Date:
Subject: Re: syntax pb