日期:2014-05-16 浏览次数:21007 次
BEGIN
declare v_bonus varchar(500);
declare v_end INT(11);
declare v_all INT(11);
declare val varchar(4000);
?DECLARE no_more_departments INT;
declare??? temp_cur cursor for SELECT b.bonus_class FROM `tms_bonus_log` b where b.programs_order_id=p_order_id;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET no_more_departments=1;
SET no_more_departments=0;
set val='';
??? open temp_cur;
????????? REPEAT
??? ??? ??? ??? ??? ??? ??? fetch temp_cur into v_bonus;
????????????? set val = CONCAT(val,v_bonus,'-');
??? UNTIL no_more_departments=1?
??? END REPEAT;
??? close temp_cur;
??? if val!='' THEN
??? ??? set v_end = CHAR_LENGTH(substring_index(val,'-',-2));
??? ??? set v_all = CHAR_LENGTH(val);
??? ??? set val = substring(val,1,v_all-v_end-1);
??? end if;
??? return val;
END