Re: BUG #8567: sql "with" for delete and update not work correctly

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: ingsis(dot)johnparra(at)gmail(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #8567: sql "with" for delete and update not work correctly
Date: 2013-11-13 03:51:23
Message-ID: CAB7nPqSafe0LQ60TwuMLbZ3og+bo8yHnSQpEXz3wD2dB=XUE_g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wed, Oct 30, 2013 at 12:32 AM, <ingsis(dot)johnparra(at)gmail(dot)com> wrote:
> The following bug has been logged on the website:
>
> Bug reference: 8567
> Logged by: John Parra
> Email address: ingsis(dot)johnparra(at)gmail(dot)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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Michael Paquier 2013-11-13 04:09:06 Re: BUG #8584: Cross Tab Queries
Previous Message Michael Paquier 2013-11-13 03:36:35 Re: BUG #8566: Postgres ODBC Driver 9.02.0100 (32 bits) cannot be used under WINDOWS 7 64 bits