Bonjour,
j'ai une routine qui (après tout un tas de calcul) ajoute des ligne à une table. Le problème c'est que cette fameuse routine ajoute deux fois la dernière ligne traitée. Je vous met les code mais je vous épargne le traitement au milieu :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
 
-- --------------------------------------------------------------------------------
-- Routine DDL
-- Note: comments before and after the routine body will not be stored by the server
-- --------------------------------------------------------------------------------
DELIMITER $$
 
CREATE DEFINER=`root`@`%` PROCEDURE `disponibilité`()
BEGIN
 
    DECLARE done INT DEFAULT 0;
    DECLARE idSoft INT;
    DECLARE nomSoft VARCHAR(255);
    DECLARE nb_tickets INT;
    DECLARE nb_interruption INT;
    DECLARE interruption_en_min INT;
    DECLARE nb_degradation INT;
    DECLARE dégradation_en_min INT;
    DECLARE tickets_sans_alteration INT;
    DECLARE taux_dispo float(6,3);
    DECLARE mois_en_cours VARCHAR(255);
 
DECLARE c CURSOR FOR 
 
/*******************
BLABLABLA tout le traitement qui initie les valeurs plus haut
*********************/
 
    DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
 
    OPEN c;
    REPEAT
     IF done = 0 THEN
        fetch c into idSoft,nomSoft,nb_tickets,nb_interruption,interruption_en_min,nb_degradation,dégradation_en_min,tickets_sans_alteration,taux_dispo,mois_en_cours;
 
            INSERT INTO `gautier`.`disponibilite_applications`(`id_software`,`mois`,`name`,`nb_total_ticket`,`nb_tickets_interruption`,`total_interruption_en_min`,`nb_tickets_degradation`,`total_dégradation_en_min`,`nb_tickets_sans_alteration_des_performances`,`taux_disponibilite`) 
            VALUES(idSoft,mois_en_cours,nomSoft,nb_tickets,nb_interruption,interruption_en_min,nb_degradation,dégradation_en_min,tickets_sans_alteration,taux_dispo);
            END IF ;
 
    UNTIL done = 1 END REPEAT;
    CLOSE c;
 
END
Le fait d'ajouter deux fois la même ligne a la fin, ça provoque une erreur de clef primaire.
Je ne sais pas comment éviter ce problème, malgré le fait que j'ai regardé sur pas mal de forums.
Merci de votre aide =)