Search Postgresql Archives

Practical question.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.gonzales@xxxxxxxxxxxxxx
WebSite:  http://www.linuxlouis.net
"Open the pod bay doors HAL!" -2001: A Space Odyssey
"Good morning starshine, the Earth says hello." -Willy Wonka



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux