item_review_bd_after_insert.sql 743 B

123456789101112131415
  1. -- dynamic sql doesn't work in store procedure or trigger.
  2. drop trigger if exists item_review_bd_after_insert;
  3. DELIMITER //
  4. create trigger item_review_bd_after_insert after insert on pro_item_review_bd
  5. for each row begin
  6. if new.score = 1 then
  7. update pro_item_revpro set score1_cnt=score1_cnt+1 where item_id = new.item_id and revindex_id = new.revindex_id;
  8. elseif new.score = 2 then
  9. update pro_item_revpro set score2_cnt=score2_cnt+1 where item_id = new.item_id and revindex_id = new.revindex_id;
  10. elseif new.score = 3 then
  11. update pro_item_revpro set score3_cnt=score3_cnt+1 where item_id = new.item_id and revindex_id = new.revindex_id;
  12. end if;
  13. end
  14. //
  15. DELIMITER ;