DELIMITER |
CREATE PROCEDURE updateTable()
BEGIN
DECLARE done INT DEFAULT 0;
DECLARE description_population_type2 TEXT;
DECLARE nom_monentite_type2 CHAR(50);
DECLARE cur1 CURSOR FOR select nom_monentite, description_population from sp_monentite where id_gp=2;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
OPEN cur1;
REPEAT
FETCH cur1 INTO nom_monentite_type2, description_population_type2;
IF NOT done THEN
UPDATE sp_monentite
SET description_population = description_population_type2
WHERE nom_monentite_type2=nom_monentite AND id_gp=1;
END IF;
UNTIL done END REPEAT;
CLOSE cur1;
END|
Procédure stockée