agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pascal+postgres@ensieve.org
Cc: pgsql-sql@postgresql.org
Subject: Re: Update Returning as subquery
Date: Sun, 10 Aug 2014 13:17:48 -0400
Message-ID: <16830.1407691068@sss.pgh.pa.us> (raw)
In-Reply-To: <F1134784-45F6-48C9-BA79-98F9BBE00051@ensieve.org>
References: <F1134784-45F6-48C9-BA79-98F9BBE00051@ensieve.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>

pascal+postgres@ensieve.org writes:
> Why is that forbidden? Isn't the purpose of a RETURNING clause to return values like a SELECT statement would, and shouldn't it therefore be allowed to occur in the same places?

An INSERT/UPDATE/DELETE RETURNING can be used as a CTE, not as a
sub-select.  Sub-selects aren't sufficiently independent of the outer
query, eg they might be evaluated more than once, or not at all, or
only partially.

			regards, tom lane


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



view thread (3+ messages)  latest in thread

Message-ID: <16830.1407691068@sss.pgh.pa.us>
Permalink:  ../16830.1407691068@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/16830.1407691068@sss.pgh.pa.us

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pascal+postgres@ensieve.org
  Subject: Re: Update Returning as subquery
  In-Reply-To: <16830.1407691068@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox