Ver Mensaje Individual
  #3 (permalink)  
Antiguo 18/02/2013, 13:51
mvlsistemas
 
Fecha de Ingreso: mayo-2004
Mensajes: 903
Antigüedad: 20 años
Puntos: 4
Respuesta: Trigger para update

Hola gracias por la respuesta.

El insert y el error

#1442 - Can't update table 'detalles_facturaproveedores' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.


Código:
INSERT INTO `detalles_facturaproveedores`(`id_factura`,`Descripcion`,`codigo_barras`,`cantidad`,`precio`,`id_producto`)
 VALUES ( 6, 'Tornillo Cabeza Exagonal 1"x1/4 cincado', '7797445000588', 3150, 110.30, 1);
INSERT INTO `detalles_facturaproveedores`(`id_factura`,`Descripcion`,`codigo_barras`,`cantidad`,`precio`,`id_producto`) 
VALUES ( 6, 'ARANDELA PLANA 1/4', '7790045001014', 3150, 130.30, 2);
Las tablas son:


Código:
CREATE TABLE `detalles_facturaproveedores` (
  `id_detalle` int(11) NOT NULL auto_increment,
  `id_factura` int(11) NOT NULL,
  `Descripcion` varchar(200) NOT NULL,
  `codigo_barras` varchar(30) default NULL,
  `cantidad` int(11) default NULL,
  `precio` decimal(18,2) default NULL,
  `id_producto` int(11) NOT NULL,
  PRIMARY KEY  (`id_detalle`,`id_factura`),
  KEY `id_factura` (`id_factura`),
  KEY `id_producto` (`id_producto`)
) ENGINE=InnoDB
Código:
CREATE TABLE `facturas_proveedores` (
  `id_factura` int(11) NOT NULL auto_increment,
  `numero` varchar(20) NOT NULL,
  `Fecha` date NOT NULL,
  `formade_pago` varchar(15) default NULL,
  `IVA` varchar(20) default NULL,
  `Descuento` smallint(6) default NULL,
  `id_proveedor` int(11) NOT NULL,
  PRIMARY KEY  (`id_factura`),
  UNIQUE KEY `numero` (`numero`),
  KEY `id_proveedor` (`id_proveedor`)
) ENGINE=InnoDB
Código:
CREATE TABLE `productos` (
  `id_producto` int(11) NOT NULL auto_increment,
  `descripcion` varchar(100) NOT NULL,
  `codigo_barras` varchar(30) default NULL,
  `medida` varchar(40) default NULL,
  `cantidad` smallint(6) default NULL,
  `precio_unitario` decimal(18,2) default NULL,
  `id_marca` int(11) NOT NULL,
  `id_subrubro` int(11) NOT NULL,
  `detalles` varchar(200) default NULL,
  PRIMARY KEY  (`id_producto`),
  UNIQUE KEY `codigo_barras` (`codigo_barras`)
) ENGINE=InnoDB