DELIMITER $
CREATE PROCEDURE generate_equipment (District Int,warehouseno VARCHAR (10))
BEGIN
DECLARE l_no VARCHAR (50);
DECLARE l_address VARCHAR (20);
DECLARE l_name VARCHAR (20);
DECLARE l_city VARCHAR (DEFAULT "Tianjin");
DECLARE L_longitude DOUBLE;
DECLARE L_latitude DOUBLE;
DECLARE L_money BIGINT;
DECLARE L_type TINYINT DEFAULT 2;
DECLARE L_rand DOUBLE;
DECLARE L_init LONG;
DECLARE l_actual LONG;
DECLARE i INT DEFAULT 0;
While i<100 do
SELECT longitude into L_longitude from warehouse WHERE No=warehouseno and district=district;
SELECT latitude into L_latitude from warehouse WHERE No=warehouseno and district=district;
SET l_address= "Address";
SET l_name= "Equipment";
SET L_rand=rand ();
SET l_no=concat (' 03Q ', ROUND (l_rand*1000000000000));
SET L_address=concat (L_address,round (l_rand*i));
SET L_name=concat (L_name,round (l_rand*i));
SET L_longitude=l_longitude+l_rand;
SET L_latitude=l_latitude+l_rand;
SET L_init=round (l_rand*30000);
SET L_actual=round (l_rand*13000);
INSERT into equipment (no,name,city,district,address,longitude,latitude,init,actual,type) VALUES (l_no,l_name,l_ City,district,l_address,l_longitude,l_latitude,l_init,l_actual,l_type);
SET i=i+1;
END while;
END;
$
DELIMITER;