日期:2014-05-16 浏览次数:20718 次
CREATE TRIGGER trigger_name trigger_time trigger_event ON tbl_name FOR EACH ROW BEGIN trigger_stmt END;
CREATE TRIGGER SetUserHome after insert ON users FOR EACH ROW BEGIN update `users` set homeLocationX = 128, homeLocationY=128, homeLocationZ=30 where uuid = NEW.uuid; END
CREATE TRIGGER SetUserHome before insert ON users FOR EACH ROW BEGIN set New.homeLocationX = 128; set New.homeLocationY = 128; set New.homeLocationZ=30; END
DROP TRIGGER [schema_name.]trigger_name;
DROP TRIGGER t_wiley_hotelComment_bu; delimiter // CREATE TRIGGER t_wiley_hotelComment_bu BEFORE UPDATE ON hotel_comment FOR EACH ROW BEGIN IF OLD.ispass=0 && NEW.ispass=1 THEN UPDATE hotel_info SET sumcommentsumcomment=sumcomment+1,sumconsumesumconsume=sumconsume+NEW.consume,sumservicesumservice=sumservice+NEW.service, sumroomsumroom=sumroom+NEW.room,sumentironsumentiron=sumentiron+NEW.entironment,totaltotal=total+(NEW.service+NEW.room+NEW.entironment) WHERE hotel_id=NEW.hotel_id; ELSEIF OLD.ispass=1 && NEW.ispass=0 THEN UPDATE hotel_info SET sumcommentsumcomment=sumcomment-1,sumconsumesumconsume=sumconsume-NEW.consume,sumservicesumservice=sumservice-NEW.service, sumroomsumroom=sumroom-NEW.room,sumentironsumentiron=sumentiron-NEW.entironment,totaltotal=total-(NEW.service+NEW.room+NEW.entironment) WHERE hotel_id=NEW.hotel_id; END IF; END;// delimiter ;