Re: Update Returning as subquery

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pascal+postgres(at)ensieve(dot)org
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Update Returning as subquery
Date: 2014-08-10 17:17:48
Message-ID: 16830.1407691068@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

pascal+postgres(at)ensieve(dot)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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message David G Johnston 2014-08-10 18:10:54 Re: Update Returning as subquery
Previous Message pascal+postgres 2014-08-10 16:15:20 Update Returning as subquery