See <http://www.mysql.com/doc/en/example-AUTO_INCREMENT.html> and <http://www.mysql.com/doc/en/Getting_unique_ID.html> for more.
Michael
Alfredo Cole wrote:
El Jue 08 Ene 2004 19:56, Paul DuBois escribió:
At 19:16 -0600 1/8/04, Alfredo Cole wrote:
Hi:
(...)
The code I use is:
select lock....
Sorry. It's select get_lock...
get code add one to code write code
release lock....
and select release_lock...
That looks like pseudo code (There is no "SELECT LOCK" statement), so it's difficult to say what this should do.
I have tried lock tables / unlock tables and it will eventually deadlock, even though the manual says it's guaranteed not to happen.
That's right. If you deadlock with table locks on MyISAM tables, something odd is going on.
But, given the nature of what you *appear* to want (get the next code in sequence), I'm curious why you don't just use an AUTO_INCREMENT column and use LAST_INSERT_ID() to retrieve the value. Is there something unusual about your requirements?
I have not tried this. I was afraid that concurrency would in some cases cause it to return the wrong code. If two users access the table at the same time, which code would each one get? The one that the last user inserted, or the correct one for the first user, and so forth?
Thank you.
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]