Re: Ok, what am I doing wrong here?

Поиск
Список
Период
Сортировка
От Marc G. Fournier
Тема Re: Ok, what am I doing wrong here?
Дата
Msg-id 20040217122000.X94474@ganymede.hub.org
обсуждение исходный текст
Ответ на Ok, what am I doing wrong here?  (Karl Denninger <karl@denninger.net>)
Список pgsql-sql
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.
>
> The query stand-alone returns a table with values that are valid for the
> table I wish to insert into.
>
> Where's my brain-fade on this?

INSERT INTO table (id, time, type) SELECT id, now(), '1' FROM secondtable;

----
Marc G. Fournier           Hub.Org Networking Services (http://www.hub.org)
Email: scrappy@hub.org           Yahoo!: yscrappy              ICQ: 7615664


В списке pgsql-sql по дате отправления:

Предыдущее
От: Jan Wieck
Дата:
Сообщение: Re: bytea or blobs?
Следующее
От: Stephan Szabo
Дата:
Сообщение: Re: Ok, what am I doing wrong here?