CREATE TRIGGER google_inventory BEFORE UPDATE ON `cataloginventory_stock_item`
FOR EACH ROW
BEGIN
update `catalog_product_entity_int`
set value=20
where attribute_id=552
and entity_id=NEW.product_id
and NEW.is_in_stock=0;
update `catalog_product_entity_int`
set value=21
where attribute_id=552
and entity_id=NEW.product_id
and NEW.is_in_stock=1;
END;
Run Code Online (Sandbox Code Playgroud)
它给了我以下错误:
1064 - 您的SQL语法出错; 检查与MySQL服务器版本对应的手册,以便在第4行的''附近使用正确的语法
我是一个SQL Server的人,不能指出问题是什么.
您需要更改分隔符.没有它,分号就会结束CREATE TRIGGER语句.
delimiter |
CREATE TRIGGER google_inventory BEFORE UPDATE ON `cataloginventory_stock_item`
FOR EACH ROW
BEGIN
update `catalog_product_entity_int`
set value=20
where attribute_id=552
and entity_id=NEW.product_id and NEW.is_in_stock=0;
update `catalog_product_entity_int`
set value=21
where attribute_id=552
and entity_id=NEW.product_id and NEW.is_in_stock=1;
END;
|
delimiter ;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
592 次 |
| 最近记录: |