现有存储过程如下:
delimiter //CREATE PROCEDURE sequence   ( IN seqName varchar(30),   IN argTime Date,   OUT val BIGINT )BEGIN 
   
  declare maxValue  int;  declare nowValue bigint;
  
  declare minValue int;
 
  select * from comm_seq  where seq_name=seqName for update;  select  max_value into maxValue  from  comm_seq  where seq_name=seqName ;  select  min_value into minValue  from  comm_seq  where seq_name=seqName ;  select  seq_value into nowValue  from  comm_seq  where seq_name=seqName ;
  if TRUNCATE(nowValue/(power(10,minValue)),0)=(date_format(argTime,'%Y%m%d%H%i%s')+0)  then   if mod(nowValue,power(10,minValue)) < power(10,maxValue) then 
  
  update comm_seq set seq_value=seq_value+1  where seq_name=seqName;  else
        
   update comm_seq set seq_value=TRUNCATE((date_format(now(),'%Y%m%d%H%i%s')+0),0)*power(10,minValue);  end if;
  
  else     update comm_seq set seq_value=TRUNCATE((date_format(argTime,'%Y%m%d%H%i%s')+0),0)*power(10,minValue);  end if;  select seq_value into val from comm_seq  where seq_name=seqName;    commit;END;//
求帮忙提升。

解决方案 »

  1.   

    把你相关的表的CREATE语句,INSERT都提供出来 。
    另外详细描述一下你所碰到的问题。
    问题说明越详细,回答也会越准确!参见如何提问。(提问的智慧
      

  2.   

    select * from comm_seq where seq_name=seqName for update;
    这句的update没什么用  去掉吧
      

  3.   

    表结构如下:
    列名                       类型                    默认值
    seq_name               varchar               
    seq_value              int                       0
    min_value              int                      4(power(10,4) 
    max_value              int                      5(power(10,5)) 想用mysql的存储过程实现id的自增长   如201109131344561234  1234为自增的序列不想用mysql自带的自增  想自己写一个存储过程实现。我是一名实习生,不知道上面的意思。是真的需要这个算法,还是让我知难而退。我只是留恋我的程序。对老板已经有了猜疑。不知道这样下去还有没有意义。