SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
CREATE TABLE `rents` ( `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, `bills` CHAR(10) NULL, PRIMARY KEY (`id`), INDEX (`bills`) ); DELIMITER $$ CREATE PROCEDURE InsertBills(IN MinRows INT, IN MaxRows INT, IN Bills CHAR(10)) BEGIN DECLARE NumRows INT; DECLARE i INT; SET i = 1; SET NumRows = CEIL(RAND() * (MaxRows - MinRows)); START TRANSACTION; WHILE i <= NumRows DO INSERT INTO `rents` (`bills`) VALUES (Bills); SET i = i + 1; END WHILE; COMMIT; END$$ DELIMITER ; CALL InsertBills(1000,2000, "PAID"); CALL InsertBills(1000,2000, "DEBT"); CALL InsertBills(1000,2000, "CANCELLED"); SELECT COUNT(1) FROM `rents`;

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear