浏览 2264 次
锁定老帖子 主题:OSWorlflow 工作流回退办法
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (1)
|
|
---|---|
作者 | 正文 |
发表时间:2009-02-07
最后修改:2009-02-07
数据库是基于mysql 5.0.45 的。前面版本对存储过程支持不是很好 主过程 rl DELIMITER $$ DROP PROCEDURE IF EXISTS `assess`.`rl`$$ CREATE DEFINER=`root`@`localhost` PROCEDURE `assess`.`rl`(entryid bigint) BEGIN DECLARE curid BIGINT; DECLARE c_previd bigint; DECLARE hisid BIGINT; DECLARE done INT default 0; DECLARE curcount int; DECLARE cur1 CURSOR FOR select id from os_currentstep where entry_id=entryid; DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1; SET AUTOCOMMIT = 0; select count(*) into curcount from os_currentstep; if curcount > 1 then START TRANSACTION; select id into curid from os_currentstep where entry_id=entryid group by entry_id; select previous_id into hisid from os_currentstep_prev where id = curid; OPEN cur1; REPEAT fetch cur1 into c_previd; delete from os_currentstep_prev where id=c_previd; delete from os_stepids where id=c_previd; UNTIL done END REPEAT; CLOSE cur1; delete from os_currentstep where entry_id=entryid; insert into os_currentstep select * from os_historystep where id=hisid; update os_currentstep set status='Underway' where id=hisid; insert into os_currentstep_prev(previous_id,id) select previous_id,id from os_historystep_prev where id=hisid; delete from os_historystep_prev where id=hisid; delete from os_historystep where id=hisid; update os_wfentry set state=1 where id=entryid; COMMIT; elseif curcount = 1 then select id into curid from os_currentstep where entry_id=entryid; call cl(curid); update os_wfentry set state=1 where id=entryid; end if; SET AUTOCOMMIT = 1; select id from os_stepids where id=0; END $$ DELIMITER ; call cl(curid); 子过程 cl DELIMITER $$ DROP PROCEDURE IF EXISTS `assess`.`cl`$$ CREATE DEFINER=`root`@`localhost` PROCEDURE `assess`.`cl`(cid bigint(20)) BEGIN DECLARE cdone INT default 0; DECLARE hisid BIGINT(20); DECLARE cur2 CURSOR FOR select previous_id from os_currentstep_prev where id=cid; DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET cdone = 1; SET AUTOCOMMIT = 0; START TRANSACTION; open cur2; repeat fetch cur2 INTO hisid; insert INTO os_currentstep select * from os_historystep where id=hisid; update os_currentstep set status='Underway' where id=hisid; insert INTO os_currentstep_prev(previous_id,id) select previous_id,id from os_historystep_prev where id=hisid; delete from os_historystep_prev where id=hisid; delete from os_currentstep_prev where id=cid; delete from os_historystep where id=hisid; UNTIL cdone END REPEAT; close cur2; delete from os_currentstep where id=cid; delete from os_stepids where id=cid; COMMIT; END $$ DELIMITER ; 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |