Re: race conditions in my sequences

Поиск
Список
Период
Сортировка
От Gregory Wood
Тема Re: race conditions in my sequences
Дата
Msg-id 019801c12687$03b79d50$7889ffcc@comstock.com
обсуждение исходный текст
Ответ на race conditions in my sequences  (Jeremy Hansen <jeremy@xxedgexx.com>)
Список pgsql-general
> Any suggestions would be more then appreciate as always.  Is there a
> better way to do what I'm trying to do?

I would recommend using only one sequence for the master table. Then just
reference that sequence value for the two foreign keys. For example:

BEGIN;
INSERT INTO Bugs (bug_date) VALUES (CURRENT_DATE);
INSERT INTO BugA (bug_id,bug_desc) VALUES (currval('bugs_bug_id_seq'),'This
is a bug');
INSERT INTO BugB (bug_id,bug_fix) VALUES (currval('bugs_bug_id'),'Reinstall
Windows... again');
COMMIT;

This way, you don't have to worry about sequences getting out of sync
because they all refer to the same value.

As for the timestamp problem... I don't know how you are trying to INSERT
those values (interface, SQL, etc).

Greg



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

Предыдущее
От: "Ben-Nes Nimrod"
Дата:
Сообщение: unix timestamp
Следующее
От: Tigran
Дата:
Сообщение: Win2K install