From: | "Gregory Wood" <gregw(at)com-stock(dot)com> |
---|---|
To: | "Jeremy Hansen" <jeremy(at)xxedgexx(dot)com> |
Cc: | "PostgreSQL-General" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: race conditions in my sequences |
Date: | 2001-08-16 19:09:45 |
Message-ID: | 019801c12687$03b79d50$7889ffcc@comstock.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Eisentraut | 2001-08-16 19:39:36 | Re: race conditions in my sequences |
Previous Message | Ben-Nes Nimrod | 2001-08-16 18:53:26 | unix timestamp |