Wednesday, March 21, 2012

Problems with multiple constraints

Hi all,

I am having a problem setting multiple constraints over a table from other table. To be more clear, I have the following code:

ALTER TABLE Solicitud_Servicio

DROP CONSTRAINT FK_Solicitud_Servicio_Domicilio;

ALTER TABLE Solicitud_Servicio

DROP CONSTRAINT FK_Solicitud_Servicio_Domicilio1;

ALTER TABLE Solicitud_Servicio ADD CONSTRAINT

FK_Solicitud_Servicio_Domicilio1 FOREIGN KEY

(

ID_Domicilio_Envio

) REFERENCES Domicilio

(

ID_Domicilio

) ON UPDATE CASCADE;

ALTER TABLE Solicitud_Servicio ADD CONSTRAINT

FK_Solicitud_Servicio_Domicilio FOREIGN KEY

(

ID_Domicilio_Facturacion

) REFERENCES Domicilio

(

ID_Domicilio

) ON UPDATE CASCADE;

As you see, I want an update on the field Domicilio.ID_Domicilio to change the fields Solicitud_Servicio.ID_Domicilio_Envio and Solicitud_Servicio.ID_Domicilio_Facturacion from my point of view there should be no problem and the weird part is that if I try this with only one constraint (either one) it works, as soon as I try to apply the other constraint I get a very annoying

“The referential relationship will result in a cyclical reference that is not allowed”

Maybe Sql Server Mobile 2005 does not support multiple constraints on a table from the same other table?

Thanks,

Flaker

Thats true. SqlCE doesn't support multiple cascade update/delete in this case. How ever it could be one update and one delete.

Thanks

Raja

No comments:

Post a Comment