At 4:17 PM -0500 2000-01-03, Bob Strouper wrote:
>Hello,
>
>I've read and read the manual and posts on the mailing
>list but still have not found the definitive answer on how
>to make a sequence table ( unique counter table ) that
>will definitly give a unique number. In my situation,
>many procceses will be reading and writing to this sequence
>table *at_the_same_time* and every proccess must read a unique number and
>write a unique number.
It doesn't matter whether or not multiple clients are accessing
the table simultaneously. The value returned by LAST_INSERT_ID()
is maintained on a per-client (per-connection) basis, and no
client can receive another client's number.
>This is what I am doing at the moment:
>
>CREATE TABLE sequence (
>ID mediumint(12) DEFAULT '0' NOT NULL auto_increment,
>PRIMARY KEY (ID)
>);
>
>...now:
>
>"UPDATE sequence SET id=last_insert_id(id+1)
>"select last_insert_id() as id from sequence";
>
>Will id now be unigue no matter what?
Yes. See above.
>
>Please help... this is really bending my mind ;-)
>
>Thanks in advance,
>Bob
>
>P.S. I really don't want to give my input in fear of
>confusing things more ;-) but the reason that I think
>that this would break is that every proccess has its
>own last_insert_id...and therefore one last_insert_id
>could be the same as an other :-(
That statement seems self-contradictory to me. If each
process has its own value, how could one be the same
as another?
--
Paul DuBois, paul@stripped