Mysql Stored Procedure example
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 (20) DEFAULT "Tianjin ";
DECLARE l_long1_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 & lt; 100 DO
SELECT longpolling INTO l_longpolling 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_longpolling = l_longpolling + 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, longdistance, latitude, init, actual, TYPE) VALUES (l_no, l_name, l_city, district, l_address, l_longdistance, l_latitude, rochelle init, Rochelle actual, Rochelle type );
SET I = I + 1;
End while;
END;
$
DELIMITER;