Hi,
I need to implement a counter and i face problem of locking so hope
that u guys can help me.
I try to do test like this :
1st connection
SELECT * FROM nextkey WHERE tblname = 'PLCN' FOR Update;
(when i execute this statement and i guess that this will lock the
record and prevent other connection to update that record right?)
2nd connection
Update nextkey SET inextkey = inextkey + 1 WHERE tblname = 'PLCN';
(I execute this in another connection after i have executed the
select for update statement in the first connection. However, this
statement does update the record!!!)
My major concern is that how can i prevent 2 ppl getting the same
counter. TQ!!!!!!!!
I am using InnoDb table + Mysql 4.0.17
I need to implement a counter and i face problem of locking so hope
that u guys can help me.
I try to do test like this :
1st connection
SELECT * FROM nextkey WHERE tblname = 'PLCN' FOR Update;
(when i execute this statement and i guess that this will lock the
record and prevent other connection to update that record right?)
2nd connection
Update nextkey SET inextkey = inextkey + 1 WHERE tblname = 'PLCN';
(I execute this in another connection after i have executed the
select for update statement in the first connection. However, this
statement does update the record!!!)
My major concern is that how can i prevent 2 ppl getting the same
counter. TQ!!!!!!!!
I am using InnoDb table + Mysql 4.0.17
Comment