除了 if 语句之外,这里的所有代码都是正确的。由于某些原因,这个 if 语句没有读取我的 var @qty_col_ctr 的值。即使我传递0,它仍然执行里面的更新。我的语法错误吗?
顺便说一句,这是 mysql 触发器内的 if 语句
if(@qty_col_ctr = 1)
then
update sample_db_name.product_inventory_tb set qty = new.sku_stock
where product_id=@product_id and department_id=@department_id;
end if;
最佳答案
您不应在触发器内为变量名称添加前缀“@”。试试这个。
if(qty_col_ctr = 1)
关于即使传递了错误的值,MYSQL TRIGGER If 语句也会执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51380362/