记录一次 MySQL 存储过程
CREATE DEFINER=`root`@`%` PROCEDURE `copyTaskToNew`(IN `originJobGroup` int,IN `targetJobGroup` int)
BEGIN
DECLARE done BOOLEAN DEFAULT 0 ;
DECLARE jobCron varchar(128) DEFAULT '0 0/3 * * * ?';
DECLARE jobDesc varchar(255) DEFAULT '';
DECLARE addTime datetime DEFAULT NULL;
DECLARE updateTime datetime DEFAULT NULL;
DECLARE author varchar(64) DEFAULT NULL;
DECLARE alarmEmail varchar(255) DEFAULT NULL;
DECLARE executorRouteStrategy varchar(50) DEFAULT NULL;
DECLARE executorHandler varchar(255) DEFAULT NULL;
DECLARE executorParam varchar(5120) DEFAULT NULL;
DECLARE executorBlockStrategy varchar(50) DEFAULT NULL;
DECLARE executorTimeout int(11) DEFAULT '0';
DECLARE executorFailRetryCount int(11) DEFAULT '0';
DECLARE glueType varchar(50) DEFAULT 'BEAN';
DECLARE glueSource mediumtext;
DECLARE glueRemark varchar(128) DEFAULT NULL;
DECLARE glueUpdatetime datetime DEFAULT NULL;
DECLARE childJobid varchar(255) DEFAULT NULL;
DECLARE cur CURSOR FOR
SELECT
job_cron as jobCron,
job_desc,
add_time,
update_time,
author,
alarm_email,
executor_route_strategy,
executor_handler,
executor_param,
executor_block_strategy,
executor_timeout,
executor_fail_retry_count,
glue_type,
glue_source,
glue_remark,
glue_updatetime,
child_jobid
FROM
XXL_JOB_QRTZ_TRIGGER_INFO
WHERE job_group = originJobGroup;
DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1 ;
OPEN cur ;
REPEAT
FETCH cur INTO
jobCron,
jobDesc,
addTime,
updateTime,
author,
alarmEmail,
executorRouteStrategy,
executorHandler,
executorParam,
executorBlockStrategy,
executorTimeout,
executorFailRetryCount,
glueType,
glueSource,
glueRemark,
glueUpdatetime,
childJobid;
INSERT INTO XXL_JOB_QRTZ_TRIGGER_INFO
(
job_group,
job_cron,
job_desc,
add_time,
update_time,
author,
alarm_email,
executor_route_strategy,
executor_handler,
executor_param,
executor_block_strategy,
executor_timeout,
executor_fail_retry_count,
glue_type,
glue_source,
glue_remark,
glue_updatetime,
child_jobid
)
VALUES
(
targetJobGroup,
jobCron,
jobDesc,
addTime,
updateTime,
author,
alarmEmail,
executorRouteStrategy,
executorHandler,
executorParam,
executorBlockStrategy,
executorTimeout,
executorFailRetryCount,
glueType,
glueSource,
glueRemark,
glueUpdatetime,
childJobid
) ;
UNTIL done
END REPEAT ;
CLOSE cur ;
END
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论