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
2469
January 26, 2016 03:00PM
969
January 27, 2016 05:21AM
715
January 31, 2016 01:37PM
756
January 27, 2016 12:18PM
770
January 27, 2016 02:01PM
769
January 27, 2016 03:03PM
716
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.