CREATE PROCEDURE 'substring_pre_map' ()
BEGIN
  DECLARE m_unit_map_filename varchar(200);
  DECLARE m_str1 int(3);
  DECLARE m_str2 int(3);
  DECLARE m_flag    int(1);
  DECLARE cur_title cursor for select unit_map_filename from t_maps_hot; 
  DECLARE continue handler for not found set m_flag = 1;
  open cur_title;
  repeat
   fetch cur_title into m_unit_map_filename;
   begin
      m_str1=substring_index(substring_index(m_unit_map_filename,'_',-2),'_',1)+2;
      m_str2=substring_index(m_unit_map_filename,'_',-1)+2;                       
      update t_maps_hot set unit_map_filename=concat('pre_map_',m_str1,'_',m_str2) where unit_map_filename=m_unit_map_filename;
   end;
  until m_flag=1
  end repeat;
  close cur_title;
end
=============================ERROR============================
错误代码: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=substring_index(substring_index(m_unit_map_filename,'_',-2),'_',1)+2;
      m_s' at line 13
(耗费 0 ms)
我的MYSQL是5.1的

解决方案 »

  1.   

    贴错了 上面的定义是
    DECLARE m_str1 varchar(200);
    DECLARE m_str2 varchar(200);错误是一样的错误
      

  2.   

    单独拿substring_index(1232131_423423_23423'_',-1)+2  完全可以执行 为什么写过程中就不可以
      

  3.   

    update t_maps_hot set unit_map_filename=concat('pre_map_',substring_index(substring_index(unit_map_filename,'_',-2),'_',1)+2,'_',substring_index(unit_map_filename,'_',-1)+2)原来一句话结束 靠!!!!!!!