mysql - Is it possible to create trigger to all tables in my database together -
how can add together trigger tables in database?
what trying create code loops through tables in database , create trigger. tried create loop loop , create trigger code giving syntax error
what need add together below code in loop can run create triggers on tables. sorry new complex sql coding.
delimiter // drop procedure if exists hunt // create procedure hunt() begin declare done int default false; declare table_name char(255); declare cur1 cursor select table_name information_schema.columns table_schema = "database" ; declare go on handler not found set done = true; open cur1; myloop: loop fetch cur1 table_name ; if done leave myloop; end if; create trigger concat('update_', table_name) before update on table_name each row begin if (new.updated_replication < old.updated_replication) signal sqlstate '45000' set message_text = 'you can\'t travel backwards in time!'; end if; end end loop; close cur1; end // delimiter ; phone call hunt(); mysql sql triggers
No comments:
Post a Comment