Re: Ok, what am I doing wrong here? - Mailing list pgsql-sql

From Stephan Szabo
Subject Re: Ok, what am I doing wrong here?
Date
Msg-id 20040217082231.C41055@megazone.bigpanda.com
Whole thread Raw
In response to Ok, what am I doing wrong here?  (Karl Denninger <karl@denninger.net>)
Responses Re: Ok, what am I doing wrong here?
List pgsql-sql
sszabo@bigpanda.com

On Tue, 17 Feb 2004, Karl Denninger wrote:

> I want to insert values from one table into another, and add some "default"
> values (that are not defaults on the table different reasons - that is, this
> is maintenance function and in normal operation there would be "real" values
> there - and null is valid)
>
> So, I want to do, for example, the following:
>
> insert into table (id, time, type) values (select id, now(), '1' from secondtable);
>
> Postgres's command line pukes on this, complaining that "select" is invalid
> inside the values part of the definition.
>
> SQL's language specification says otherwise, as does "\h insert" from the
> command line.

I think what you want is
insert into table (id, time, type) select id, now(), '1' from secondtable;

The choices allowed right now are default values, something that is
basically a row constructor with values [*] or a query.

[*] - The full spec allows a list of row constructors but we don't
currently.



pgsql-sql by date:

Previous
From: "Marc G. Fournier"
Date:
Subject: Re: Ok, what am I doing wrong here?
Next
From: Tomasz Myrta
Date:
Subject: Re: Ok, what am I doing wrong here?