Skip site navigation (1) Skip section navigation (2)

Re: UPDATE...RETURNING col INTO var - what is returned?

From: Alban Hertroys <dalroi(at)solfertje(dot)student(dot)utwente(dot)nl>
To: Rainer Pruy <Rainer(dot)Pruy(at)Acrys(dot)COM>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: UPDATE...RETURNING col INTO var - what is returned?
Date: 2010-05-27 17:12:38
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-general
On 27 May 2010, at 18:12, Rainer Pruy wrote:

> Hi all,
> I just got quite confused on the exact semantics
> of "RETURNING expressions INTO target" with an update statement.
> And while trying to resolve failed to find an answer in the  docs.
> Question was whether - in case "expression" is involving a column that is assigned by the update itself -
> the value returned is based on the "old" value or the "new" value".
> While I'm no back to assuming is has to be the "old" one,
> I did not find a reference to that fact with the docs.

I'm pretty sure it's the new value, since that's what INSERT...RETURNING returns - very convenient if the value you inserted was generated somehow (by a sequence for example).
Since you can also UPDATE some column using a generated value, it'd make sense if it would behave the same way.

Alban Hertroys

Screwing up is an excellent way to attach something to the ceiling.


In response to


pgsql-general by date

Next:From: Josh BerkusDate: 2010-05-27 18:11:51
Subject: Re: List traffic
Previous:From: Justin GrafDate: 2010-05-27 16:36:20
Subject: Re: Please help me write a query

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group