Bonjour,
j'ai un problème pour la mise a jour de mes tables de ma bd MySQL. Mes commandes php me donnent des messages d'erreurs. Je ne sais pas comment faire pour UPDATE des tables quand elles contiennent des clefs étrangères d'autres tables.
Voila mes tables :
ma table mission (table mère) :
create table mission(CodeMission Int(5),Details Varchar(50),Groupement Varchar(2),Lieu Varchar(50),Datedebut date,Datefin date,Previsible boolean,PRIMARY KEY(CodeMission,Groupement,DateDebut,DateFin));
ma table avoir :
create table avoir(CodeMission Int(5),Groupement Varchar(2),Datedebut date,Datefin date,FamilleMission Varchar(50),PRIMARY KEY(CodeMission,Groupement,Datedebut,Datefin,FamilleMission),FOREIGN KEY(CodeMission,Groupement,Datedebut,Datefin) REFERENCES mission(CodeMission,Groupement,Datedebut,Datefin),FOREIGN KEY(FamilleMission) REFERENCES type_mission(FamilleMission));
ma table est_effectuee :
create table est_effectuee(Matricule Varchar(12),CodeMission Int(5),Groupement Varchar(2),Datedebut date,Datefin date,Nbrejours decimal(5,2),EngComptableJournee decimal(8,2),EngComptableTotal decimal(8,2),PrixPaye decimal(8,2),Prime decimal(5,2),PRIMARY KEY(Matricule,CodeMission,Groupement,Datedebut,Datefin),FOREIGN KEY(Matricule) REFERENCES reserviste(Matricule),FOREIGN KEY(CodeMission,Groupement,Datedebut,Datefin) REFERENCES mission(CodeMission,Groupement,Datedebut,Datefin));
lorsque j'update ma table mission :
$mysql_query("UPDATE mission set Codemission=7777 where Codemission=1");
il y a ce message d'erreur :
#1451 - Cannot delete or update a parent row: a foreign key constraint fails (`gendarmerie/avoir`, CONSTRAINT `avoir_ibfk_1` FOREIGN KEY (`CodeMission`, `Groupement`, `Datedebut`, `Datefin`) REFERENCES `mission` (`CodeMission`, `Groupement`, `Datedebut`, `Datefin`))
lorsque j'update ma table avoir:
$mysql_query("UPDATE avoir set Codemission=7777 where Codemission=1");
#1452 - Cannot add or update a child row: a foreign key constraint fails (`gendarmerie/avoir`, CONSTRAINT `avoir_ibfk_1` FOREIGN KEY (`CodeMission`, `Groupement`, `Datedebut`, `Datefin`) REFERENCES `mission` (`CodeMission`, `Groupement`, `Datedebut`, `Datefin`))
lorsque j'update ma table est_effectuee :
$mysql_query("UPDATE est_effectuee set Codemission=7777 where Codemission=1");
#1452 - Cannot add or update a child row: a foreign key constraint fails (`gendarmerie/est_effectuee`, CONSTRAINT `est_effectuee_ibfk_2` FOREIGN KEY (`CodeMission`, `Groupement`, `Datedebut`, `Datefin`) REFERENCES `mission` (`CodeMission`, `Groupement`, `Datedebut`,)
Mon but est de modifier la valeur de CodeMission pour les 3 tables (la nouvelles valeursest identique pour les 3 tables )
Si vous pouvez m'éclairer voir me donner le code me permettant de remédier à ce problème .
Merci de votre aide.
Partager