Re: referencing other INSERT VALUES columns inside the insert

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: referencing other INSERT VALUES columns inside the insert
Дата
Msg-id CAKFQuwaRYYUXyrv5qz7_YOiDMqEmDy-K1nTvosfq_nHh9XMp2A@mail.gmail.com
обсуждение исходный текст
Ответ на Re: referencing other INSERT VALUES columns inside the insert  (Geoff Winkless <pgsqladmin@geoff.dj>)
Ответы Re: referencing other INSERT VALUES columns inside the insert  (Geoff Winkless <pgsqladmin@geoff.dj>)
Список pgsql-general
On Mon, Nov 16, 2015 at 4:06 AM, Geoff Winkless <pgsqladmin@geoff.dj> wrote:
On 16 November 2015 at 10:55, Albe Laurenz <laurenz.albe@wien.gv.at> wrote:
What about something along these lines:

INSERT INTO test (c1, c2, c3)
   (WITH fixed(x1, x2) AS (VALUES (3, 7))
    SELECT x1, x2, x1 * x2 FROM fixed);

​Genius!

It never occured to me that the with_query parameter could be used that way. Thanks!


​You don't need WITH to accomplish this...

INSERT INTO test (c1, c2, c3)
SELECT c1, c2, c1 * c2
FROM ( VALUES (3, 7) ) vals (c1, c2);

David J.
 

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

Предыдущее
От: Cj B
Дата:
Сообщение: bdr appears to be trying to replicate to itself
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: bdr appears to be trying to replicate to itself