| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- use trs_data_migration;
- DROP PROCEDURE IF EXISTS p_data_migration_wcmtemplateemploy;
- DELIMITER $$
- CREATE PROCEDURE p_data_migration_wcmtemplateemploy(IN prevTemplateEmployId BIGINT(20),
- IN templateEmployIdOffset BIGINT(20),
- IN templateIdOffset BIGINT(20),
- IN siteIdOffset BIGINT(20),
- IN channelIdOffset BIGINT(20))
- BEGIN
-
- DECLARE isover INT DEFAULT 0;
- DECLARE f_TEMPLATEEMPLOYID int(11) DEFAULT '0';
- DECLARE f_EMPLOYERTYPE int(11) DEFAULT '0';
- DECLARE f_EMPLOYERID int(11) DEFAULT '0';
- DECLARE f_TEMPLATEID int(11) DEFAULT '0';
- DECLARE f_TEMPLATETYPE smallint(6) DEFAULT '0';
- DECLARE f_ISDEFAULT smallint(6) DEFAULT '0';
- DECLARE cur CURSOR FOR
- SELECT
- TEMPLATEEMPLOYID,
- EMPLOYERTYPE,
- EMPLOYERID,
- TEMPLATEID,
- TEMPLATETYPE,
- ISDEFAULT
- FROM trs_data_migration.wcmtemplateemploy
- ORDER BY TEMPLATEEMPLOYID asc;
- DECLARE CONTINUE HANDLER FOR NOT FOUND SET isover = 1;
-
- OPEN cur;
-
- FETCH cur INTO
- f_TEMPLATEEMPLOYID,
- f_EMPLOYERTYPE,
- f_EMPLOYERID,
- f_TEMPLATEID,
- f_TEMPLATETYPE,
- f_ISDEFAULT
- ;
- WHILE isover= 0 DO
- # 断点续传
- IF (f_TEMPLATEEMPLOYID > prevTemplateEmployId)
- THEN
- SET @TEMPLATEEMPLOYID = f_TEMPLATEEMPLOYID;
- SET f_TEMPLATEEMPLOYID = f_TEMPLATEEMPLOYID + templateEmployIdOffset;
- SET f_TEMPLATEID = f_TEMPLATEID + templateIdOffset;
- IF (f_EMPLOYERTYPE = 103)
- THEN SET f_EMPLOYERID = f_EMPLOYERID + siteIdOffset;
- END IF ;
- IF (f_EMPLOYERTYPE = 101)
- THEN SET f_EMPLOYERID = f_EMPLOYERID + channelIdOffset;
- END IF ;
- insert into trs_hycloud_iip.wcmtemplateemploy
- (
- TEMPLATEEMPLOYID,
- EMPLOYERTYPE,
- EMPLOYERID,
- TEMPLATEID,
- TEMPLATETYPE,
- ISDEFAULT
- )
- VALUES
- (
- f_TEMPLATEEMPLOYID,
- f_EMPLOYERTYPE,
- f_EMPLOYERID,
- f_TEMPLATEID,
- f_TEMPLATETYPE,
- f_ISDEFAULT
- );
- SET @sql = trs_data_migration.build_migration_log_sql('wcmtemplateemploy', @TEMPLATEEMPLOYID);
- prepare stmt from @sql;
- EXECUTE stmt;
- deallocate prepare stmt;
- END IF ;
- FETCH cur INTO
- f_TEMPLATEEMPLOYID,
- f_EMPLOYERTYPE,
- f_EMPLOYERID,
- f_TEMPLATEID,
- f_TEMPLATETYPE,
- f_ISDEFAULT
- ;
-
- END WHILE;
-
- CLOSE cur;
- SET @sql = trs_data_migration.build_migration_log_sql('wcmtemplateemploy', -1);
- prepare stmt from @sql;
- EXECUTE stmt;
- deallocate prepare stmt;
-
- END $$
- DELIMITER ;
|