Radicore Forum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » RADICORE » How To » How to deal with multiple inserts in ADD1 pattern
Re: How to deal with multiple inserts in ADD1 pattern [message #5884 is a reply to message #5882] Mon, 19 September 2016 14:17 Go to previous messageGo to previous message
AJM is currently offline  AJM
Messages: 2371
Registered: April 2006
Location: Surrey, UK
Senior Member
According to the MySQL manual it is simply not possible for multiple inserts into a table which has an auto-increment primary key to fail with a duplicate key error. Each insert will increment the number, so it is not possible for the same number to be returned for different inserts. I cannot duplicate this supposed bug in my system.

the logs you have provided show a primary key with the value "ABC123" so as it is not pure numeric it cannot be an auto-increment column.

If using an ADD1 pattern the user presses the SUBMIT button more than once then the insert will be attempted more than once. If the primary key is a user-supplied value then this will result in a "duplicate key" error.

If different users try to insert a record with the same primary key at the same time then the first insert will succeed and all others will fail. This is expected behaviour. Each INSERT operation is surrounded by a START TRANSACTION and a COMMIT/ROLLBACK during which the database is locked. Perhaps you need to examine your locking strategy.



 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: List sibling records given a child record
Next Topic: need help
Goto Forum:
  


Current Time: Thu Nov 28 10:59:44 EST 2024

Total time taken to generate the page: 0.00906 seconds