0
la procédure donne une erreur comme:procédure de troncature pour tous les enregistrements
Script line: 4 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'cmd;
EXECUTE stmt;
DROP PREPARE stmt;
- Fin de la boucle U » à la ligne 25
pls me corriger quelqu'un, remercier u dans advqance ..
DELIMITER $$
DROP PROCEDURE IF EXISTS `CR_SP_TRUNCATE1` $$
CREATE PROCEDURE `CR_SP_TRUNCATE1`()
BEGIN
-- Declare local variables
DECLARE done BOOLEAN DEFAULT 0;
DECLARE cmd VARCHAR(2000);
-- Declare the cursor
DECLARE cmds CURSOR FOR
SELECT CONCAT('TRUNCATE TABLE ', TABLE_NAME) FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA ='icbadwh' and TABLE_NAME LIKE 'cr%';
-- Declare continue handler
DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done=1;
-- Open the cursor
OPEN cmds;
-- Loop through all rows
REPEAT
-- Get order number
FETCH cmds INTO cmd;
-- Execute the command
PREPARE stmt FROM cmd;
EXECUTE stmt;
DROP PREPARE stmt;
-- End of loop
UNTIL done END REPEAT;
-- Close the cursor
CLOSE cmds;
END $$
DELIMITER ;