Re: serialization errors when inserting new records

Поиск
Список
Период
Сортировка
От Ralph van Etten
Тема Re: serialization errors when inserting new records
Дата
Msg-id Pine.LNX.4.44.0501241153170.2282-100000@exp-toy.et10.loc
обсуждение исходный текст
Ответ на Re: serialization errors when inserting new records  (William Yu <wyu@talisys.com>)
Список pgsql-general
On Mon, 24 Jan 2005, William Yu wrote:

> If you absolutely need the display field to be unique and it has to be a
> sequence starting from 1 -- it's simplicity itself. Use the
> serialization errors to your advantage. If you try to insert a record
> and you get a dupe key violation, just increment your seq counter by 1
> and try again. Keep trying until you succeed. No need to lock the tables
> at all.

Just trial and error ?
I don't think its a very good solution. Then you have to figure out
exactly which error it is and which column caused the violation. (How ? By
parsing the error string ???)
And if the correct error was returned you retry the query... But how many
times ? Just once ? or a 1000 times ?
I'm sorry but I think this solution is just a Q&D hack.


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

Предыдущее
От: Stefan Sturm
Дата:
Сообщение: Savepoint Problem
Следующее
От: Postgres General
Дата:
Сообщение: disable trigger from transaction