Re: BUG #8567: sql "with" for delete and update not work correctly - Mailing list pgsql-bugs

From Michael Paquier
Subject Re: BUG #8567: sql "with" for delete and update not work correctly
Date
Msg-id CAB7nPqSafe0LQ60TwuMLbZ3og+bo8yHnSQpEXz3wD2dB=XUE_g@mail.gmail.com
Whole thread Raw
In response to BUG #8567: sql "with" for delete and update not work correctly  (ingsis.johnparra@gmail.com)
List pgsql-bugs
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

pgsql-bugs by date:

Previous
From: Michael Paquier
Date:
Subject: Re: BUG #8566: Postgres ODBC Driver 9.02.0100 (32 bits) cannot be used under WINDOWS 7 64 bits
Next
From: Michael Paquier
Date:
Subject: Re: BUG #8584: Cross Tab Queries