item_review_after_insert.sql 896 B

12345678910111213141516171819
  1. -- dynamic sql doesn't work in store procedure or trigger.
  2. drop trigger if exists item_review_after_insert;
  3. DELIMITER //
  4. create trigger item_review_after_insert after insert on pro_item_review
  5. for each row begin
  6. if new.rating_score = 1 then
  7. update pro_item_revsum set score1_cnt=score1_cnt+1 where id = new.item_id;
  8. elseif new.rating_score = 2 then
  9. update pro_item_revsum set score2_cnt=score2_cnt+1 where id = new.item_id;
  10. elseif new.rating_score = 3 then
  11. update pro_item_revsum set score3_cnt=score3_cnt+1 where id = new.item_id;
  12. elseif new.rating_score = 4 then
  13. update pro_item_revsum set score4_cnt=score4_cnt+1 where id = new.item_id;
  14. elseif new.rating_score = 5 then
  15. update pro_item_revsum set score5_cnt=score5_cnt+1 where id = new.item_id;
  16. end if;
  17. end
  18. //
  19. DELIMITER ;