Re: Replaceing records

Поиск
Список
Период
Сортировка
От Shridhar Daithankar
Тема Re: Replaceing records
Дата
Msg-id 3F5761BB.23467.77CB3C@localhost
обсуждение исходный текст
Ответ на Re: Replaceing records  (Csaba Nagy <nagy@ecircle-ag.com>)
Список pgsql-general
On 4 Sep 2003 at 12:17, Csaba Nagy wrote:

> This problem would be easily solved if the current transaction would not
> be automatically rolled back on the failed insert. Given this, it would
> be as easy as trying the insert, and if fails, do the update.

That violates definition of a transaction. You need nested transaction which
aren't there..

You can use a sequence to insert. If next value of sequence is more than value
you have, probably somebody has inserted the value. Then modify it.

Or do a select for update. If it returns the error, there is no record. So
insert, otherwise update.

It might still fail though but chances will be much less.

HTH

Bye
 Shridhar

--
Air Force Inertia Axiom:    Consistency is always easier to defend than
correctness.


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

Предыдущее
От: Peter Childs
Дата:
Сообщение: Re: Optimizer picks an ineffient plan
Следующее
От: "Bjorn T Johansen"
Дата:
Сообщение: Re: Tomcat Connection Pool?