07-06-2012, 11:24 AM
Here is a much shorter one(plus your has some problems for instance a_count does not exist)
DROP PROCEDURE IF EXISTS check_inventory;
CREATE PROCEDURE check_inventory()
BEGIN
-- init stuff
SET @i = 0;
SET @str_inven = "t_inven0";
SET @str_count = "a_count";
-- for every table
WHILE @i <= 9 DO
SET @t_inven = CONCAT(@str_inven, @i);
SET @j = 0;
-- for every columns
WHILE @j <= 4 DO
SET @a_count = CONCAT(@str_count, @j);
-- prepare statemets and execute it
SET @q = CONCAT("UPDATE ",@t_inven, " SET ", @a_count, " = 0 WHERE ", @a_count, " > 10000000000;");
PREPARE stmt FROM @q; EXECUTE stmt; DEALLOCATE PREPARE stmt;
SET @j = @j + 1;
END WHILE;
SET @i = @i + 1;
END WHILE;
END;
CALL check_inventory();

