Thread: BUG #8567: sql "with" for delete and update not work correctly
BUG #8567: sql "with" for delete and update not work correctly
From
ingsis.johnparra@gmail.com
Date:
The following bug has been logged on the website: Bug reference: 8567 Logged by: John Parra Email address: ingsis.johnparra@gmail.com PostgreSQL version: 9.2.4 Operating system: Fedora 19 Description: To executed an query with reserved word "with del as (...) delete from ...= (select id from del)" and had to run more than once.
On Wed, Oct 30, 2013 at 12:32 AM, <ingsis.johnparra@gmail.com> wrote: > The following bug has been logged on the website: > > Bug reference: 8567 > Logged by: John Parra > Email address: ingsis.johnparra@gmail.com > PostgreSQL version: 9.2.4 > Operating system: Fedora 19 > Description: > > To executed an query with reserved word "with del as (...) delete from ...= > (select id from del)" and had to run more than once. You are not giving much information here... But I'd guess that you forgot to add a RETURNING clause, necessary with a DML inside WITH: =# create table aa (a int); CREATE TABLE =# insert into aa values (generate_series(1,5)); INSERT 0 5 =# with del1 as (delete from aa where a = 1 or a = 3 returning a) select * from del1; a --- 1 3 (2 rows) =# select * from aa; a --- 2 4 5 (3 rows) Regards, -- Michael