Re: [SQL] Use select and update together

2011-09-17 Thread Tom Lane
Guillaume Lelarge writes: > On Sat, 2011-09-17 at 16:56 +0200, Andreas wrote: >> 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?

Re: [SQL] Use select and update together

2011-09-17 Thread Guillaume Lelarge
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

Re: [SQL] Use select and update together

2011-09-17 Thread Andreas
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 obvio

Re: [SQL] Use select and update together

2011-09-13 Thread Samuel Gendler
On Mon, Sep 12, 2011 at 3:36 AM, Boris wrote: > > SELECT ( > UPDATE tbl SET val = 1 > WHERE KEY = any('{0,1,2,3,4,5}'::int[]) > returning key > ); > > cause syntax error. Is any query of such type (update warped into > select) is possible? > > Just lose the select ();

Re: [SQL] Use select and update together

2011-09-12 Thread pasman pasmański
In 8.4 this syntax is not implemented. 2011/9/12, Boris : > Hi, this is my first on this list. > > I can't understand where my problem in PG 8.4. > > CREATE TABLE tbl( KEY int, val int); > > Update query like: > > UPDATE tbl SET val = 1 > WHERE KEY = any('{0,1,2,3,4,5}'::int[]) >

[SQL] Use select and update together

2011-09-12 Thread Boris
Hi, this is my first on this list. I can't understand where my problem in PG 8.4. CREATE TABLE tbl( KEY int, val int); Update query like: UPDATE tbl SET val = 1 WHERE KEY = any('{0,1,2,3,4,5}'::int[]) returning key; work well. But any try to wrap it in select query like: