Oct 27 2023 10:55 AM
MY BETOPTIONS TABLE DESIGN
ID COUNT
1 100
2 200
3 45
4 2
LIKE THIS
MY STORED PROCEDURE IS LIKE THIS
CREATE PROCEDURE BUYLOTTOGAME
BEGIN TRANS
SELECT @COUNT=COUNT FROM TABLENAME WITH UPDLOCK WHERE ID=@ID
IF @COUNT>=@SOMECOUNT
BEGIN
ROLLBACK TRAN
RETURN
END
UPDATE TABLENAME SET COUNT=COUNT+@INCONT WHERE ID=@ID
COMMIT TRAN
WILL THIS CODE HANDLE CONCURRENCY ISSUE WITHOUT DEADLOCK
INDEX NON CLUSTERED INDEX ON ID
Nov 01 2023 12:36 AM
@HELJEEVE , what could case here a deadlock and why do you expect one?
A deadlock can only occur if two or more process accesses two or more resources and this in different order; that's here not the case.
Nov 04 2023 05:11 AM
Nov 05 2023 10:11 PM