1

后端 - MySQL 5.1.52 社区前端 - MS Access 2007

我有两张表 POLIZAS 和 TRAMITES(都是 InnoDB)我使用 Access 作为前端。我需要在 Tramites 上插入/更新记录,有时 Tramites 与 Polizas 不相关。

Tramites 有一个允许 null 的 Polizas 外键。但是在插入/更新时仍然出现此错误:

[MySQL][ODBC 5.1 Driver][mysqld-5.1.52-community]无法添加或更新子行:外键约束失败('cartera_bd'.'tramites',CONSTRAINT 'fk_tramites_polizas1' FOREIGN KEY ('Poliza') REFERENCES '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;

这是 TRMITES 表说明

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