xiechao198609150053
Alex01101
2018-08-24 10:08
采纳率: 66.7%
浏览 1.2k

mysql触发器没有执行,求指导!

insert,update商品数据时需要把content中只截取前8个图片
tirgger语句:
create trigger tri_goods_update AFTER UPDATE
on ims_ewei_shop_goods for each row
begin
set @gcount = (SELECT CAST((LENGTH('content') - LENGTH(REPLACE('content',"absmiddle", ""))) / LENGTH("absmiddle") AS signed) AS count FROM ims_ewei_shop_goods where id = new.id);
IF @gcount > 8 AND locate('

',old.content) = 0 THEN
update ims_ewei_shop_goods set content = CONCAT(substring_index(old.content,'absmiddle',-(@gcount - 8)),'absmiddle" >') where id = new.id;
END IF;
END
触发器创建,和修改执行后没有报错,content中的数据没有改变.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • liuzc120
    liuzc120 2018-08-24 13:18
    已采纳

    触发器不要更新自己会造成循环,使用navica工具看看表上触发器是否成功,内容和选项是否正确

    点赞 评论
  • zqbnqsdsmd
    zqbnqsdsmd 2018-08-24 10:11
    点赞 评论

相关推荐