1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
-- 如果存在此存储过程则删掉
DROP PROCEDURE IF EXISTS proc_initData;
-- 定好结束符为"$"
DELIMITER $
-- 创建
CREATE PROCEDURE proc_initData()
BEGIN
-- 定义变量
DECLARE i INT DEFAULT 1;
DECLARE line INT DEFAULT 101;
DECLARE idqty INT DEFAULT 201;
DECLARE c INT DEFAULT 1;
-- 循环插入数据
WHILE i<=800 DO
INSERT INTO ds_position(id,areaid,prow,pcol,pictype,remarks,del_flag)
VALUES(CONCAT('h-1_',idqty),'h-1',line,c,'empty',0,0);
SET idqty = idqty+1;
SET i = i+1;
-- id先除以2然后乘2 如果与原来的相等就是偶数
IF i =( i >> 1 )<< 1
THEN SET c = 2;
ELSE
SET line = line + 1;
SET c = 1;
END IF;
END WHILE;
COMMIT;
-- 结束
END $
CALL proc_initData();
|