  | |  | Concurrent Insert - Locking the database | Concurrent Insert - Locking the database 2005-02-22 - By Pradeep
Back I have a perl function which inserts a record into mysql database. The function looks something like
sub insertRecord { $pkey = getLatestKey() + 1; executeQuery("insert into tablename values($pkey,......)"); }
getLatestKey() { $a = executeQuery("select max(pkey) from tablename"); return $a; }
This is fine for non-concurrent insert. But, multiple users will be using this at the same time to insert records, which may create problem.
Suppose max(pkey) is 1500. If two users executes concurrently, user 1 must get 1501 and user 2 must get 1502. How to achieve this ?
Regards, Pradeep
-- MySQL Windows Mailing List For list archives: http://lists.mysql.com/win32 To unsubscribe: http://lists.mysql.com/win32?unsub=mysql@(protected)
Earn $52 per hosting referral at Lunarpages.
|
|
 |