56,682
社区成员
发帖
与我相关
我的任务
分享
DROP TABLE IF EXISTS `tt`;
CREATE TABLE `tt` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) DEFAULT NULL,
`reccount` int(11) DEFAULT NULL,
`dt` date DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=gbk;
-- ----------------------------
-- Records of tt
-- ----------------------------
INSERT INTO `tt` VALUES ('1', 'a', '10', '2016-08-01');
INSERT INTO `tt` VALUES ('2', 'a', '11', '2016-08-03');
INSERT INTO `tt` VALUES ('3', 'a', '12', '2016-08-04');
INSERT INTO `tt` VALUES ('4', 'b', '8', '2016-08-01');
INSERT INTO `tt` VALUES ('5', 'b', '15', '2016-08-05');
CREATE PROCEDURE `aa`(istart int(11),ilen int(11))
BEGIN
DECLARE c int default 0;
DECLARE done INT DEFAULT 0;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
declare continue handler for 1172 set done=2;
declare continue handler for 1062 set done=3;
set c = istart;
while c < istart + ilen do
insert into days VALUES( DATE_FORMAT(DATE_ADD(NOW(),INTERVAL c DAY), '%Y-%m-%d'));
set c=c+1;
end while;
END