Search Postgresql Archives

syntax pb

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux