The BEGIN
DECLARE VALUE1 INTEGER;
The UPDATE xuliehao
The SET CURRENT_VALUE=https://bbs.csdn.net/topics/CURRENT_VALUE + 1
Where seq_name=seq_name1;
The SET VALUE1=0;
The SELECT CURRENT_VALUE INTO VALUE1
The FROM xuliehao
WHERE seq_name=seq_name1;
Return VALUE1.
END
======
Run time sometimes gets stuck, seems to be a deadlock, don't know how to solve the
Add transaction did not add, don't know whether mysql function supports transactions, how to ensure that
Take the correctness of the data when concurrent
CodePudding user response:
Mysql has on the columns is good tooCodePudding user response:
1) the function of the mysql support transaction2) suggest directly using MYSQL itself auto_increment to achieve more convenient, if it is more than one table/column need to reference the same SEQUENCE, can consider to create a create table seqA (s int auto_increment primary key); Then in the storage function, to insert the data in the table to get S LAST_INSERT_ID ()