Mysql存储过程使用多个游标的处理
时间:2019-02-18 12:46 来源:linux.it.net.cn 作者:IT
Mysql存储过程使用多个游标的处理
定义数据库表
DROP TABLE IF EXISTS `student`;
CREATE TABLE `student` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) DEFAULT NULL,
`score` varchar(255) DEFAULT NULL,
`update_time` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
`create_time` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of student
-- ----------------------------
INSERT INTO `student` VALUES ('1', 'ronnie', '100', '2016-04-14 10:44:01', '2016-04-14 10:44:06');
INSERT INTO `student` VALUES ('2', 'john', '95', '2016-04-14 10:44:22', '2016-04-14 10:44:25');
INSERT INTO `student` VALUES ('3', 'mark', '90', '2016-04-14 10:44:32', '2016-04-14 10:44:35');
调用存储过程
CALL test_loop(@count);
SELECT @count;
查看结果
结果为6
(责任编辑:IT)
Mysql存储过程使用多个游标的处理
定义数据库表
DROP TABLE IF EXISTS `student`;
CREATE TABLE `student` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) DEFAULT NULL,
`score` varchar(255) DEFAULT NULL,
`update_time` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
`create_time` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of student
-- ----------------------------
INSERT INTO `student` VALUES ('1', 'ronnie', '100', '2016-04-14 10:44:01', '2016-04-14 10:44:06');
INSERT INTO `student` VALUES ('2', 'john', '95', '2016-04-14 10:44:22', '2016-04-14 10:44:25');
INSERT INTO `student` VALUES ('3', 'mark', '90', '2016-04-14 10:44:32', '2016-04-14 10:44:35');
调用存储过程
CALL test_loop(@count);
SELECT @count;
查看结果
结果为6
(责任编辑:IT) |