I'm at PostgreSQL 8.3 for my production database and everything is
working great. I had no problems converting free text search from 8.2 to
8.3, and I really like the improvements.
I tried using insert ... delete ... return ... and get a syntax error:
> pccyber=# insert into product_manufacturer_archived (itemno,
> pccyber-# delete from product_manufacturer
> pccyber-# where not exists (select * from icitem
> pccyber(# where icitem.itemno =
> product_manufacturer.itemno and
> pccyber(# not inactive)
> pccyber-# returning itemno, manufacturer_id;
> ERROR: syntax error at or near "delete"
> LINE 2: delete from product_manufacturer
The goal here is to move inactive records to an archived table. This is
to be performed as part of a daily batch job instead of as a trigger.
Assume my model is correct - my question isn't how can I do this. I
would like to know if insert .. delete .. returning is intended to work
In the past I've executed insert ... select and then the delete.
However, I believe there is race condition here as the delete may see
more or less rows than the insert ... select. I thought the above would
be a clever PostgreSQL-8.3 alternative, but I'm either stupid or it
doesn't work... :-)
Mark Mielke <mark(at)mielke(dot)cc>
pgsql-hackers by date
|Next:||From: Guillaume Smet||Date: 2008-02-24 21:39:03|
|Subject: Re: insert ... delete ... returning ... ?|
|Previous:||From: Florian G. Pflug||Date: 2008-02-24 19:25:34|
|Subject: Re: Behaviour of rows containg not-null domains in plpgsql|