insert into d'une table reliant deux tables(foreign key)
voila mon problème :
Citation:
Warning: mssql_query() [function.mssql-query]: message: L'instruction INSERT est en conflit avec la contrainte FOREIGN KEY 'FK_necessiter_prestation'. Le conflit s'est produit dans la base de données 'e_gest', table 'dbo.prestation', column 'noprestation'. (severity 16) in C:\wamp\www\E-GEST\listeprestation.php on line 259
Warning: mssql_query() [function.mssql-query]: Query failed in C:\wamp\www\E-GEST\listeprestation.php on line 259
Code:
1 2 3 4 5 6 7 8 9 10
|
create table necessiter
(noprestation int not null
,numintervenant int not null
,CONSTRAINT PK_necessiter PRIMARY KEY (noprestation, numintervenant)
,CONSTRAINT FK_necessiter_prestation FOREIGN KEY (noprestation) REFERENCES prestation (noprestation)
,CONSTRAINT FK_necessiter_intervenant FOREIGN KEY (numintervenant) REFERENCES intervenant (numintervenant))
go |
Code:
1 2 3
|
$requete="INSERT INTO necessiter (noprestation, numintervenant) values ('" . $noprestation . "', '" . $numintervenant . "')";
$resultat= mssql_query($requete,$connexion); |