pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Guillaume Lelarge <guillaume@lelarge.info>
To: Andreas <maps.on@gmx.net>
Cc: pgsql-sql@postgresql.org
Subject: Re: Use select and update together
Date: Sat, 17 Sep 2011 17:51:10 +0200
Message-ID: <1316274671.2203.2.camel@localhost.localdomain> (raw)
In-Reply-To: <4E74B538.8080902@gmx.net>
References: <CAH4qf7Z=q0XVF-2bPL0Ag3mQREUqCLHgJEGcdPP66XMTd6n_7A@mail.gmail.com>
	<CAOWY8=bpkoexYaoqGJf42Fo4Zprj6TwmV6OukKvQkJSEg=Gqxw@mail.gmail.com>
	<4E74B538.8080902@gmx.net>

On Sat, 2011-09-17 at 16:56 +0200, Andreas wrote:
> Am 13.09.2011 07:50, schrieb pasman pasmaƄski:
> > In 8.4 this syntax is not implemented.
> 
> select * from (
> update tbl set val = 1 where key in ( 1, 2, 3, 4, 5 ) returning *
> ) as x
> 
> wouldn't work even in PG 9.1.
> So what data structure is coming out of an "update ... returning *" 
> statement?
> It obviously doesn't work like a subquery.
> 

The only way to make something like this work in 9.1 would be:

WITH x AS
(update tbl set val = 1 where key in ( 1, 2, 3, 4, 5 ) returning *)
SELECT * FROM x;


-- 
Guillaume
  http://blog.guillaume.lelarge.info
  http://www.dalibo.com




view thread (6+ messages)  latest in thread

Message-ID: <1316274671.2203.2.camel@localhost.localdomain>
Permalink:  ../1316274671.2203.2.camel@localhost.localdomain/
Also on:    postgresql.org/message-id/1316274671.2203.2.camel@localhost.localdomain

 · 

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: guillaume@lelarge.info, maps.on@gmx.net
  Subject: Re: Use select and update together
  In-Reply-To: <1316274671.2203.2.camel@localhost.localdomain>

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

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