请检查以下触发器:
DELIMITER $$
CREATE TRIGGER shop_balance_insert AFTER INSERT ON shop_transfers
FOR EACH ROW
BEGIN
DECLARE PROD_CODE VARCHAR(50);
DECLARE SUBCAT_ID INTEGER;
DECLARE COLOR_ID INTEGER;
DECLARE SIZE_ID INTEGER;
SELECT product_code,subcat_id,color_id,size_id INTO PROD_CODE,SUBCAT_ID,COLOR_ID,SIZE_ID FROM inventories WHERE bar_code =NEW.barcode LIMIT 0,1;
INSERT INTO shop_product_balance(product_code, subcat_id,color_id,size_id ,barcode,shop_id,tbl_name,tbl_date,tbl_primary_key,trns_to_qty,trns_from_qty,sold_qty,return_qty, trnsStatus_st) VALUES
(PROD_CODE, SUBCAT_ID ,COLOR_ID , SIZE_ID, NEW.barcode, NEW.tshopID,'shop_transfers', NEW.trnsDT, NEW.transferID, NEW.qty,0,0,0,0);
INSERT INTO shop_product_balance(product_code, subcat_id,color_id,size_id ,barcode,shop_id,tbl_name,tbl_date,tbl_primary_key,trns_to_qty,trns_from_qty,sold_qty,return_qty, trnsStatus_st) VALUES
(PROD_CODE, SUBCAT_ID,COLOR_ID , SIZE_ID ,NEW.barcode, NEW.fshopID,'shop_transfers', NEW.trnsDT, NEW.transferID,0, NEW.qty,0,0,1);
END $$
DELIMITER ;
触发器工作得很好,直到只有一个变量prod\u代码。我最近添加了其他三个变量-subcat,size,color。但是现在-新的三列(subcat、size、color)的值没有显示在表中。其他列的值工作正常。
[注意:列的数据类型与此处声明的相同]
我在声明或设置变量时是否犯了错误。
暂无答案!
目前还没有任何答案,快来回答吧!