Atomic operations?

Поиск
Список
Период
Сортировка
От Paul Tomblin
Тема Atomic operations?
Дата
Msg-id 8efd35820803180640vf1090dcx8dc1da8b340a1dac@mail.gmail.com
обсуждение исходный текст
Ответы Re: Atomic operations?  (Dave Cramer <pg@fastcrypt.com>)
Список pgsql-jdbc
Ok, I've already written about how my app uses autocommit (although I
have a side project to fix that so you don't need to lecture me about
how bad that is).

I'm doing a simple delete/insert on a table, rather than trying to
figure out whether the row exists or not and then doing an update or
an insert.  But what I'm discovering is that every now and then I get
a duplicate primary key exception, so I figure that two processes are
doing the deletes and inserts and stomping on each other.  So my
question is about combining the delete and insert into one
PreparedStatement.  I've never combined two statements like that, but
somebody on this list mentioned it earlier.  If I say
   PreparedStatement ps = conn.prepareStatement(
      "DELETE FROM venue WHERE venueid = ? ; INSERT INTO VENUE
(venueid, .... ) VALUES(?, ?, ?, ?)");
Does that work?  Will that be atomic so that nobody else can insert
one with that venueid in between the delete and the insert?

--
For my assured failures and derelictions I ask pardon beforehand of my
betters and my equals in my Calling here assembled, praying that in
the hour of my temptations, weakness and weariness, the memory of this
my Obligation and of the company before whom it was entered into, may
return to me to aid, comfort and restrain.

В списке pgsql-jdbc по дате отправления:

Предыдущее
От: "Woody Woodring"
Дата:
Сообщение: Re: JDBC rewriting a bad query?
Следующее
От: robert engels
Дата:
Сообщение: Re: setQueryTimeout problem !?!?!