problema con violates foreign key constraint
Publicado por zendi (132 intervenciones) el 23/03/2015 00:32:27
estoy tratando de crear un registro en una tabla con este INSERT:
PERO ME ARROJA ESTE ERROR:
ERROR: insert or update on table "consulta" violates foreign key constraint "consulta_id_paciente_fkey"
SQL state: 23503
Detail: Key (id_paciente)=(3) is not present in table "paciente".
NO DEBIERA DAR EL ERROR YA QUE EL CAMPO ID_PACIENTE DE LA TABLA PACIENTE ESTA RELACIONADO CON EL CAMPO ID_PACIENTE DE LA TABLA CONSULTA, Y ES DE UNO A MUCHOS LO CUAL INDICA QUE LA TABLA CONSULTA TIENE QUE RECIBIR MUCHAS CONSULTAS DE UN PACIENTE.
POR FAVOR SI ALGUIEN PUDIERA AYUDARME.
1
2
3
4
5
6
7
8
9
10
11
INSERT INTO consulta( id_medico, fecha, peso, talla,
circunfcefalica, circunfbrazo, observacion, meses, anios,
hepatitisa, hepatitisb, polio, fiebreamarilla, difteriatetanos,
varicela, meningitis, haemophilusinfluenza, sarampion, rubeola,
parotiditis, vph, rotavirus, tuberculosis, alergiap, amigdalp,
anemiap, apendicitisp, asmap, bronquip, denguep, dabdominalp,
chinkungunyap, colerap, gripep, hepap, hepabp, meninp, otitisp,
parotidap, sarampp, vphp) VALUES (1, '2015-03-22', 0, 0, 0, 0, 'uiuiuuuiiuiu',
0, 1, 1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
ERROR: insert or update on table "consulta" violates foreign key constraint "consulta_id_paciente_fkey"
SQL state: 23503
Detail: Key (id_paciente)=(3) is not present in table "paciente".
NO DEBIERA DAR EL ERROR YA QUE EL CAMPO ID_PACIENTE DE LA TABLA PACIENTE ESTA RELACIONADO CON EL CAMPO ID_PACIENTE DE LA TABLA CONSULTA, Y ES DE UNO A MUCHOS LO CUAL INDICA QUE LA TABLA CONSULTA TIENE QUE RECIBIR MUCHAS CONSULTAS DE UN PACIENTE.
POR FAVOR SI ALGUIEN PUDIERA AYUDARME.
Valora esta pregunta


0