Re: referencing other INSERT VALUES columns inside the insert

From: Geoff Winkless <pgsqladmin(at)geoff(dot)dj>
To: Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at>
Cc: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: referencing other INSERT VALUES columns inside the insert
Date: 2015-11-16 11:06:53
Message-ID: CAEzk6femufwosHW__YcMUFaKCqRqmPd++2Omp-cP5pMnZZQgkg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 16 November 2015 at 10:55, Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)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!

Geoff

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message John R Pierce 2015-11-16 11:31:37 Re: DB_link connection
Previous Message Albe Laurenz 2015-11-16 10:55:03 Re: referencing other INSERT VALUES columns inside the insert