Error extraño en llave foranea

From: Lazaro Ruben Garcia Martinez <lgarciam(at)vnz(dot)uci(dot)cu>
To: "pgsql-es-ayuda(at)postgresql(dot)org" <pgsql-es-ayuda(at)postgresql(dot)org>
Subject: Error extraño en llave foranea
Date: 2014-02-18 16:03:08
Message-ID: 294D3D02D5E18D42827B2ECFEADEB688BA081E5891@mx-interno.vnz.uci.cu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

Hola a todos en la lista, les escribo porque estoy teniendo un error sobre una llave foránea y no comprendo que puede estar pasando.

Tengo una tabla llamada tbl_cita_planificacion, cuya clave primaria está compuesta por tres columnas:

Esta es la defición de la tabla:

CREATE TABLE public.tbl_cita_planificacion (
fecha DATE NOT NULL,
hora_inicio TIME WITHOUT TIME ZONE NOT NULL,
hora_fin TIME WITHOUT TIME ZONE NOT NULL,
cupos INTEGER NOT NULL,
ncl_tipo_seccion INTEGER NOT NULL,
ncl_tipo_documento INTEGER NOT NULL,
CONSTRAINT tbl_cita_planificacion_pkey PRIMARY KEY(fecha, ncl_tipo_seccion, ncl_tipo_documento),
CONSTRAINT fk_cp_tipo_documento FOREIGN KEY (ncl_tipo_documento)
REFERENCES public.tbl_ntipo_documento(pk_tipo_documento)
ON DELETE NO ACTION
ON UPDATE NO ACTION
NOT DEFERRABLE,
CONSTRAINT fk_cp_tipo_seccion FOREIGN KEY (ncl_tipo_seccion)
REFERENCES public.tbl_ntipo_seccion(pk_tipo_seccion)
ON DELETE NO ACTION
ON UPDATE NO ACTION
NOT DEFERRABLE
) WITHOUT OIDS;

la tabla es referenciada en otra tabla y sucede que cuando realizo un update sobre esta tabla me lanza un error de integridad referencial:

ERROR: insert or update on table "tbl_tramite_cita" violates foreign key constraint "fk_tpc_fecha_tipo_documento_tipo_seccion"
DETAIL: Key (fecha, ncl_tipo_documento, ncl_tipo_seccion)=(2014-02-22, 1, 2) is not present in table "tbl_cita_planificacion".

Sin embargo esta tupla que me marca como que no existe, si existe.

Alguien me podría ayudar a detectar el error, porque le he dado muchas vueltas al asunto y no encuentro el error. La versión de PG que estoy usando es 9.2.5.

Saludos a todos.

Fin a la injusticia, LIBERTAD AHORA A NUESTROS CINCO COMPATRIOTAS QUE SE ENCUENTRAN INJUSTAMENTE EN PRISIONES DE LOS EEUU!
http://www.antiterroristas.cu
http://justiciaparaloscinco.wordpress.com

-
Enviado a la lista de correo pgsql-es-ayuda (pgsql-es-ayuda(at)postgresql(dot)org)
Para cambiar tu suscripción:
http://www.postgresql.org/mailpref/pgsql-es-ayuda

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Lazaro Ruben Garcia Martinez 2014-02-18 16:40:31 RE: Error extraño en llave foranea
Previous Message Ruben Fitó 2014-02-18 12:09:04 Re: SELECT a partir de un BITMAP