Use select and update together

From: Boris <kuzikoff(at)ukr(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Subject: Use select and update together
Date: 2011-09-12 10:36:12
Message-ID: CAH4qf7Z=q0XVF-2bPL0Ag3mQREUqCLHgJEGcdPP66XMTd6n_7A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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:

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?

Best regards, Kuzikov Borys

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message pasman pasmański 2011-09-13 05:50:10 Re: Use select and update together
Previous Message Craig Ringer 2011-09-12 01:31:35 Re: FW: Hi