BEGIN
declare _cur int;  
declare _curdate char(10);  

set _curdate=(select DATE_FORMAT(sysdate(),'%Y%m%d'));
set _cur=(select current_value from sequence_batchno where name=_curdate);

IF IFNULL(_cur,-1)<0 THEN
set _cur=0;
    insert into sequence_batchno values(DATE_FORMAT(sysdate(),'%Y%m%d'),1,1);
ELSE
    update sequence_batchno  
  set current_value = _cur + _increment  
  where name=_curdate;
END IF;
return _cur;
END

 

结果:

mysql函数根据日期每天生成一个sequence

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-03
  • 2022-12-23
  • 2021-06-27
  • 2021-11-20
猜你喜欢
  • 2022-12-23
  • 2021-09-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-29
  • 2021-11-13
  • 2022-12-23
相关资源
相似解决方案