insert,update商品數(shù)據(jù)時(shí)需要把content中只截取前8個(gè)圖片tirgger語(yǔ)句:create trigger tri_goods_update AFTER UPDATEon ims_ewei_shop_goods for each rowbeginset @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 THENupdate ims_ewei_shop_goods set content = CONCAT(substring_index(old.content,'absmiddle',-(@gcount - 8)),'absmiddle" >') where id = new.id;END IF;END觸發(fā)器創(chuàng)建,和修改執(zhí)行后沒(méi)有報(bào)錯(cuò),content中的數(shù)據(jù)沒(méi)有改變.
2 回答

白豬掌柜的
TA貢獻(xiàn)1893條經(jīng)驗(yàn) 獲得超10個(gè)贊
觸發(fā)器不要更新自己會(huì)造成循環(huán),使用navica工具看看表上觸發(fā)器是否成功,內(nèi)容和選項(xiàng)是否正確
添加回答
舉報(bào)
0/150
提交
取消