我想从运动服更新库存表,尺寸从t0到tXXXL,每个尺寸都是基础数据中的一列,因此要更新每个尺寸的存货,我发送尺寸,其购买数量和可用库存。 我试图创建一个触发器,但是没有用,所以我把它留在了一个有效的过程中,直到添加了这句话。
DROP PROCEDURE IF EXISTS `ActualizarInventario`;
/*nombre=name of Team for example=Barcelona, Real Madrid, Lakers, Bulls etc.
cant=Quantity sold
talla=size.
stock=quantities available.
The columns are in VARCHAR*/
CREATE DEFINER = `root`@`localhost` PROCEDURE `ActualizarInventario`(IN
nombre VARCHAR(40),IN cant VARCHAR(15),IN talla VARCHAR(15),IN stock
VARCHAR(15))
BEGIN
INSERT INTO Ventas_Uniforme VALUES(null,nombre,talla,cant,stock,NOW());
#This UPDATE it does not work
UPDATE inventario AS inv SET talla =(CAST(stock AS INT)-CAST(cant AS
INT))
WHERE inv.Nombre_Agregar=nombre;
END;
#This is the trigger that I try to make, but gave the same error.
UPDATE inventario AS inv SET new.Talla =(CAST(new.Stock AS INT)-
CAST(new.Cantidad_Venta AS INT)) WHERE
inv.Nombre_Agregar=new.Nombre_Uniforme
当我执行它时,这会把我扔掉。
过程执行失败 1054-“字段列表”中的未知列“ talla”