1

バックエンド-MySQL5.1.52コミュニティフロントエンド-MSAccess2007

2つのテーブルPOLIZASとTRAMITES(両方ともInnoDB)があり、フロントエンドとしてAccessを使用しています。TramitesがまだPolizasに関連付けられていない場合がある、Tramitesのレコードを挿入/更新する必要があります。

Tramitesには、nullを許可するPolizasへの外部キーがあります。しかし、それでも挿入/更新時にこのエラーが発生します:

[MySQL] [ODBC5.1ドライバー][mysqld-5.1.52-community]子行を追加または更新できません:外部キー制約が失敗します('cartera_bd'。'tramites'、CONSTRAINT'fk_tramites_polizas1' FOREIGN KEY('Poliza')参照'polizas'('Poliza')ON DELETE CASCADE ON UPDATE CASCADE)(#1452)

手がかりはありますか?

これはPOLIZASテーブルの説明です

CREATE TABLE `polizas` (
`Poliza` varchar(20) NOT NULL,
`IdAgente` mediumint(8) unsigned NOT NULL,
`IdPlan` tinyint(3) unsigned NOT NULL,
`IdCliente` int(10) unsigned NOT NULL,
`RenuevaA` varchar(20) DEFAULT NULL,
`InicioVigencia` date NOT NULL,
`IdTipoDerechos` tinyint(1) unsigned NOT NULL,
`IdConducto` tinyint(1) unsigned NOT NULL,
`IdFormaPago` tinyint(1) unsigned NOT NULL,
`IdMoneda` tinyint(1) unsigned NOT NULL,
`PrimaNeta` decimal(11,2) NOT NULL,
`Recargos` decimal(11,2) DEFAULT NULL,
`Derechos` decimal(11,2) DEFAULT NULL,
`IVA` decimal(11,2) DEFAULT NULL,
`PrimaTotal` decimal(11,2) NOT NULL,
`Status` tinyint(1) unsigned NOT NULL,
`Notas` varchar(150) DEFAULT NULL,
`FechaEmision` date DEFAULT NULL,
PRIMARY KEY (`Poliza`),
KEY `IdAgente` (`IdAgente`),
KEY `IdCliente` (`IdCliente`),
KEY `IdConducto` (`IdConducto`),
KEY `IdFormaPago` (`IdFormaPago`),
KEY `IdMoneda` (`IdMoneda`),
KEY `IdPlan` (`IdPlan`),
KEY `IdTipoDerechos` (`IdTipoDerechos`),
KEY `fk_polizas_status1` (`Status`),
CONSTRAINT `fk_polizas_agentes1` FOREIGN KEY (`IdAgente`) REFERENCES `agentes` (`ID`) ON DELETE NO ACTION ON UPDATE CASCADE,
CONSTRAINT `fk_polizas_clientes1` FOREIGN KEY (`IdCliente`) REFERENCES `clientes` (`ID`) ON DELETE NO ACTION ON UPDATE CASCADE,
CONSTRAINT `fk_polizas_conducto1` FOREIGN KEY (`IdConducto`) REFERENCES `conducto` (`ID`) ON DELETE NO ACTION ON UPDATE CASCADE,
CONSTRAINT `fk_polizas_formapago1` FOREIGN KEY (`IdFormaPago`) REFERENCES `formapago` (`ID`) ON DELETE NO ACTION ON UPDATE CASCADE,
CONSTRAINT `fk_polizas_moneda1` FOREIGN KEY (`IdMoneda`) REFERENCES `moneda` (`ID`) ON DELETE NO ACTION ON UPDATE CASCADE,
CONSTRAINT `fk_polizas_planes1` FOREIGN KEY (`IdPlan`) REFERENCES `planes` (`ID`) ON DELETE NO ACTION ON UPDATE CASCADE,
CONSTRAINT `FK_polizas_status1` FOREIGN KEY (`Status`) REFERENCES `status` (`ID`) ON DELETE NO ACTION ON UPDATE CASCADE,
CONSTRAINT `fk_polizas_tipoderechos1` FOREIGN KEY (`IdTipoDerechos`) REFERENCES `tipoderechos` (`ID`) ON DELETE NO ACTION ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

これはTRAMITESテーブルの説明です

CREATE TABLE `tramites` (
`IdTramite` int(11) NOT NULL AUTO_INCREMENT,
`IdTipoTramite` tinyint(1) unsigned NOT NULL,
`Folio` int(11) DEFAULT NULL,
`Poliza` varchar(20) DEFAULT NULL,
`Inicio` date NOT NULL,
`Fin` date DEFAULT NULL,
`Tramite` text,
`Dias` int(11) DEFAULT NULL,
`IdCliente` int(10) unsigned DEFAULT NULL,
PRIMARY KEY (`IdTramite`),
KEY `fk_tramites_polizas1` (`Poliza`),
KEY `fk_tramites_tipotramite1` (`IdTipoTramite`),
KEY `fk_tramites_clientes1` (`IdCliente`) USING BTREE,
CONSTRAINT `fk_tramites_polizas1` FOREIGN KEY (`Poliza`) REFERENCES `polizas` (`Poliza`) ON DELETE NO ACTION ON UPDATE CASCADE,
CONSTRAINT `fk_tramites_tipotramite1` FOREIGN KEY (`IdTipoTramite`) REFERENCES `tipotramite` (`Id`) ON DELETE NO ACTION ON UPDATE CASCADE,
CONSTRAINT `FK_tramite_clientes1` FOREIGN KEY (`IdCliente`) REFERENCES `clientes` (`ID`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;
4

0 に答える 0