CREATE PROCEDURE a1()
BEGIN
DECLARE v1 INT DEFAULT 100;
WHILE v1 > 0 DO
SET v1 = v1 - 1;
INSERT INTO system_company VALUES (UUID(), '1490150781669', '2017-03-22 10:46:21', CONCAT('公司',v1), '123123', '1231');
END WHILE;
END;
call a1();
CREATE PROCEDURE aaaa13()
BEGIN
-- 需要定义接收游标数据的变量
DECLARE ctid VARCHAR(255);
DECLARE cpname VARCHAR(255);
DECLARE houname VARCHAR(255);
DECLARE b INT;
DECLARE v1 INT DEFAULT 100;
DECLARE v2 INT DEFAULT 4;
-- 游标
DECLARE cur CURSOR FOR SELECT table_id,commanyname from system_company;
-- 遍历数据结束标志
declare continue handler for not found set b=1;
-- 将结束标志绑定到游标
-- 打开游标
open cur;
/* 循环开始 */
myLoop: LOOP
/* 移动游标并赋值 */
FETCH cur INTO ctid, cpname;
if b = 1 then
leave myLoop;
end if;
/* 执行代码*/
set v1=100;
WHILE v1 > 0 DO
SET v1 = v1 - 1;
set v2=v2+1;
set houname = CONCAT('houzhuo',v2);
INSERT INTO system_user VALUES (UUID(), '1490256132035', '2017-03-23 16:02:12', '1', '1',houname, '123', 'asdasd', cpname, 'sdasd', 'asdasd');
END WHILE;
/* 循环结束 */
end loop myLoop;
close cur;
END
call aaaa13();
CREATE PROCEDURE c1()
BEGIN
-- 需要定义接收游标数据的变量
DECLARE ctid VARCHAR(255);
DECLARE cpname VARCHAR(255);
DECLARE houname VARCHAR(255);
DECLARE b INT;
DECLARE v1 INT DEFAULT 100;
DECLARE v2 INT DEFAULT 4;
DECLARE devid INT DEFAULT 100000;
DECLARE carId VARCHAR(255);
-- 游标
DECLARE cur CURSOR FOR SELECT table_id,commanyname from system_company;
-- 遍历数据结束标志
declare continue handler for not found set b=1;
-- 将结束标志绑定到游标
-- 打开游标
open cur;
/* 循环开始 */
myLoop: LOOP
/* 移动游标并赋值 */
FETCH cur INTO ctid, cpname;
if b = 1 then
leave myLoop;
end if;
/* 执行代码*/
set v1=100;
WHILE v1 > 0 DO
SET v1 = v1 - 1;
set v2=v2+1;
set devid=devid+1;
set houname = CONCAT('houzhuo',v2);
set carId =UUID();
INSERT INTO system_car VALUES (carId, '1490150799257', '2017-03-22 10:46:39', 'tt', 'tttt', 'ttt', 'ttt', '2929-M6', devid, null, null);
INSERT INTO system_device VALUES (null, devid, '0', '0', '1', '58.6', '116.66556', '31.11154', null, '30', '22.2', '11.1', '-2.2', '-0.5', null, null, null, null, null, null, null, '1899', null, null, '310', null, null, null, null, null);
INSERT INTO system_car_company VALUES (UUID(), null, null, carId, ctid);
END WHILE;
/* 循环结束 */
end loop myLoop;
close cur;
END
call c1();