From: | louis gonzales <gonzales(at)linuxlouis(dot)net> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Practical question. |
Date: | 2007-03-16 03:14:50 |
Message-ID: | 45FA0BAA.9030606@linuxlouis.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello List,
I want to write a statement-level trigger - one that happens once per
statement - such that, immediately after an insert into a table(which
gets a unique integer value as an ID from a defined sequence, being the
primary key on the table), a new table is created with foreign key
constraint on that unique ID.
My concern is with what happens if two such inserts occur at almost the
same time, what is the best way to ensure that I never miss the creation
of one of the tables due to the 2nd one, possibly reading the same "max"
or nextvalue that the immediate previous trigger read.
As an example:
insertX which initiates the trigger reads the 'nextvalue' from the
sequence and begins to create the associcated table
insertY happens almost at the same time, so that it gets the same
'nextvalue' from the sequence and would then create or attempt to create
the 'same' assoicated table while missing it's 'true' 'nextvalue'.
Thanks for any insight!
--
Email: louis(dot)gonzales(at)linuxlouis(dot)net
WebSite: http://www.linuxlouis.net
"Open the pod bay doors HAL!" -2001: A Space Odyssey
"Good morning starshine, the Earth says hello." -Willy Wonka
From | Date | Subject | |
---|---|---|---|
Next Message | Randall Smith | 2007-03-16 03:30:06 | Re: pre-parser query manipulation |
Previous Message | Tom Lane | 2007-03-16 02:20:47 | Re: Role & User - Inheritance? |