Hi all:

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, manufacturer_id)
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 or not.

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... :-)

Any ideas?

Thanks,
mark

--
Mark Mielke <[EMAIL PROTECTED]>


---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Reply via email to