CREATE DEFINER=`root`@`%` FUNCTION `split_pid`(str varchar (1000),delimiter varchar(1)) RETURNS varchar(200) CHARSET utf8 begin declare cur_str varchar(200); declare sub_len int; declare sub_str varchar(200); declare ret_str varchar(200); declare loop_count int; set cur_str = str; set sub_len = -1; set ret_str = ''; set loop_count = 0; repeat set cur_str = substring(cur_str,sub_len + 2); set sub_str = substring_index(cur_str,delimiter,1); set sub_len = length(sub_str); if sub_len !=0 then set ret_str = concat(ret_str,lpad(sub_str,6,'0')); end if; set loop_count = loop_count + 1; until sub_len = 0 end repeat; return ret_str; end |
0
|
|