MySQL Forums
Forum List  »  Stored Procedures

Lock a row
Posted by: Russel James
Date: January 26, 2016 03:00PM

It is possible to lock a row so that only one user can access it at a time ?

I have a sproc that increments a value and returns the new value as follows:


CREATE DEFINER=`root`@`localhost` PROCEDURE `usp_SystemControlGetNextPLInvNumber`()
BEGIN


/* LOCK */
UPDATE systemControl SET PLInvNumber = PLInvNUmber + 1;

Select PLInvNUmber FROM systemControl;
/* UNLOCK */

END

But I want to make sure the the same number is never returned twice.

Can this be done ?

J

Options: ReplyQuote


Subject
Views
Written By
Posted
Lock a row
2294
January 26, 2016 03:00PM
847
January 27, 2016 05:21AM
614
January 31, 2016 01:37PM
645
January 27, 2016 12:18PM
666
January 27, 2016 02:01PM
672
January 27, 2016 03:03PM
578
January 29, 2016 06:49PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.