Re: Re: can't get UPDATE ... RETURNING ... INTO ... to compile successfully - Mailing list pgsql-general

From Alvaro Herrera
Subject Re: Re: can't get UPDATE ... RETURNING ... INTO ... to compile successfully
Date
Msg-id 20080819144909.GA4428@alvh.no-ip.org
Whole thread Raw
In response to Re: Re: can't get UPDATE ... RETURNING ... INTO ... to compile successfully  (Bill Moran <wmoran@collaborativefusion.com>)
Responses Re: Re: can't get UPDATE ... RETURNING ... INTO ... to compile successfully  (Bill Moran <wmoran@collaborativefusion.com>)
Re: Re: can't get UPDATE ... RETURNING ... INTO ... to compile successfully  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Bill Moran wrote:

> Is it possible that your UPDATE command is updating multiple rows?  I
> don't believe RETURNING will work on an UPDATE that touches more than 1
> row.

Hmm, why not?

alvherre=> create table bill (a int, b text);
CREATE TABLE
alvherre=> insert into bill values (1, 'one');
INSERT 0 1
alvherre=> insert into bill values (2, 'two');
INSERT 0 1
alvherre=> update bill set b = a || ' ' || b returning b;
   b
-------
 1 one
 2 two
(2 lignes)

UPDATE 2


--
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: How to execute 'set session role' from plpgsql function?
Next
From: Bill Moran
Date:
Subject: Re: Re: can't get UPDATE ... RETURNING ... INTO ... to compile successfully