Thread: why doesn't insert into foo delete from bar returning baz work?

why doesn't insert into foo delete from bar returning baz work?

From
Palle Girgensohn
Date:
While you can do

insert into foo (a, b) select a, b from bar;

and

delete from bar where a=1 returning a, b;

it fails to run

insert into foo (a, b) delete from bar where a=1 returning a, b;

This is not what I would expect. Is there a reason for it not working?

Cheers
Palle


Re: why doesn't insert into foo delete from bar returning baz work?

From
Merlin Moncure
Date:
On Wed, May 26, 2010 at 11:17 AM, Palle Girgensohn <girgen@pingpong.net> wrote:
> While you can do
>
> insert into foo (a, b) select a, b from bar;
>
> and
>
> delete from bar where a=1 returning a, b;
>
> it fails to run
>
> insert into foo (a, b) delete from bar where a=1 returning a, b;
>
> This is not what I would expect. Is there a reason for it not working?

everyone wants this.  it was slated to be included for 9.0 but the
patch had to be pulled due to technical problems.

merlin

Re: why doesn't insert into foo delete from bar returning baz work?

From
Andreas Kretschmer
Date:
Palle Girgensohn <girgen@pingpong.net> wrote:

> While you can do
>
> insert into foo (a, b) select a, b from bar;
>
> and
>
> delete from bar where a=1 returning a, b;
>
> it fails to run
>
> insert into foo (a, b) delete from bar where a=1 returning a, b;
>
> This is not what I would expect. Is there a reason for it not working?

Yeah, it's a great feature, called writeable CTE, see here:

http://akretschmer.blogspot.com/2009/11/writeable-cte-short-performance-test.html

Unfortunately, the patch from Mirko Tiikkaja was rejected due to some
technical problems. I'm waiting for 9.1 ...


Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect.                              (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly."   (unknown)
Kaufbach, Saxony, Germany, Europe.              N 51.05082°, E 13.56889°