DROP DATABASE IF EXISTS `test_tg`; CREATE DATABASE `test_tg`; USE `test_tg`; CREATE TABLE `table_a` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `table_b_id` int(10) unsigned, `table_c_id` int(10) unsigned DEFAULT NULL, `table_d_id` int(10) unsigned DEFAULT NULL, `field_1` varchar(200) NOT NULL, `field_2` varchar(10000) NOT NULL, `field_3` tinyint(1) NOT NULL DEFAULT '0', `field_4` varchar(1000) DEFAULT NULL, `field_5` varchar(1000) DEFAULT NULL, `field_6` varchar(1000) DEFAULT NULL, `field_7` varchar(1000) DEFAULT NULL, `field_8` varchar(100) NOT NULL DEFAULT '', `field_9` datetime DEFAULT NULL, `field_10` varchar(100) DEFAULT NULL, PRIMARY KEY (`id`), KEY `table_a_id_field_10` (`id`,`field_10`), KEY `table_a_field_5` (`field_5`), KEY `table_a_table_b_id` (`table_b_id`), KEY `table_a_table_c_id` (`table_c_id`), KEY `table_a_table_d_id` (`table_d_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `table_b` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `field_2` varchar(1000) NOT NULL, `field_3` varchar(1000) DEFAULT NULL, `field_4` varchar(1000) DEFAULT NULL, `field_5` varchar(1000) DEFAULT NULL, `field_6` varchar(100) DEFAULT NULL, PRIMARY KEY (`id`), KEY `table_b_field_2` (`field_2`), KEY `table_b_field_3` (`field_3`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `table_c` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `field_2` varchar(10000) NOT NULL, `field_3` varchar(5000) DEFAULT NULL, `field_4` varchar(3000) DEFAULT NULL, `field_5` varchar(1000) DEFAULT NULL, `field_6` varchar(100) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `table_d` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `field_2` varchar(10) NOT NULL, `field_3` varchar(10) DEFAULT NULL, `field_4` varchar(10) DEFAULT NULL, `field_5` varchar(10) DEFAULT NULL, `field_6` varchar(10) DEFAULT NULL, PRIMARY KEY (`id`), KEY `table_d_field_2` (`field_2`), KEY `table_d_field_3` (`field_3`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; INSERT INTO `table_b` VALUES (NULL, 'CREATE TRIGGER table_b_before_insert BEFORE INSERT ON table_b FOR EACH ROW CREATE TRIGGER table_b_before_insert BEFORE INSERT ON table_b FOR EACH ROW CREATE TRIGGER table_b_before_insert BEFORE INSERT ON table_b FOR EACH ROW CREATE TRIGGER table_b_before_insert BEFORE INSERT ON table_b FOR EACH ROW CREATE TRIGGER table_b_before_insert BEFORE INSERT ON table_b FOR EACH ROW CREATE TRIGGER table_b_before_insert BEFORE INSERT ON table_b FOR EACH ROW ', 'CREATE TRIGGER table_b_before_insert BEFORE INSERT ON table_b FOR EACH ROW CREATE TRIGGER table_b_before_insert BEFORE INSERT ON table_b FOR EACH ROW CREATE TRIGGER table_b_before_insert BEFORE INSERT ON table_b FOR EACH ROW CREATE TRIGGER table_b_before_insert BEFORE INSERT ON table_b FOR EACH ROW ', 'CREATE TRIGGER table_b_before_insert BEFORE INSERT ON table_b FOR EACH ROW CREATE TRIGGER table_b_before_insert BEFORE INSERT ON table_b FOR EACH ROW CREATE TRIGGER table_b_before_insert BEFORE INSERT ON table_b FOR EACH ROW ', 'CREATE TRIGGER table_b_before_insert BEFORE INSERT ON table_b FOR EACH ROW CREATE TRIGGER table_b_before_insert BEFORE INSERT ON table_b FOR EACH ROW CREATE TRIGGER table_b_before_insert BEFORE INSERT ON table_b FOR EACH ROW ', '3eb493bd346411e4b1c4120a7699a4ab'); INSERT INTO `table_c` VALUES (NULL, 'CREATE TRIGGER table_b_before_insert BEFORE INSERT ON table_b FOR EACH ROW CREATE TRIGGER table_b_before_insert BEFORE INSERT ON table_b FOR EACH ROW CREATE TRIGGER table_b_before_insert BEFORE INSERT ON table_b FOR EACH ROW CREATE TRIGGER table_b_before_insert BEFORE INSERT ON table_b FOR EACH ROW CREATE TRIGGER table_b_before_insert BEFORE INSERT ON table_b FOR EACH ROW CREATE TRIGGER table_b_before_insert BEFORE INSERT ON table_b FOR EACH ROW ', 'CREATE TRIGGER table_b_before_insert BEFORE INSERT ON table_b FOR EACH ROW CREATE TRIGGER table_b_before_insert BEFORE INSERT ON table_b FOR EACH ROW CREATE TRIGGER table_b_before_insert BEFORE INSERT ON table_b FOR EACH ROW CREATE TRIGGER table_b_before_insert BEFORE INSERT ON table_b FOR EACH ROW ', 'CREATE TRIGGER table_b_before_insert BEFORE INSERT ON table_b FOR EACH ROW CREATE TRIGGER table_b_before_insert BEFORE INSERT ON table_b FOR EACH ROW CREATE TRIGGER table_b_before_insert BEFORE INSERT ON table_b FOR EACH ROW ', 'CREATE TRIGGER table_b_before_insert BEFORE INSERT ON table_b FOR EACH ROW CREATE TRIGGER table_b_before_insert BEFORE INSERT ON table_b FOR EACH ROW CREATE TRIGGER table_b_before_insert BEFORE INSERT ON table_b FOR EACH ROW ', '3eb493bd346411e4b1c4120a7699a4ab'); DELIMITER ;; /*** table_b ***/ CREATE TRIGGER table_b_before_insert BEFORE INSERT ON table_b FOR EACH ROW this_proc: BEGIN DECLARE vChange TEXT DEFAULT ''; DECLARE vChangeUser TEXT DEFAULT 'NONE'; IF CHAR_LENGTH(IFNULL(@audit_triggers_disabled,''))>0 THEN LEAVE this_proc; END IF; IF CHAR_LENGTH(IFNULL(@audit_username,''))>0 THEN SET vChangeUser = @audit_username; END IF; SET vChange = CONCAT(NEW.id,NEW.field_2 ,NEW.field_3 ,NEW.field_4 ,NEW.field_5 ,NEW.field_6); IF CHAR_LENGTH(IFNULL(NEW.field_2 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(NEW.field_2 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(NEW.field_3 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(NEW.field_4 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(NEW.field_5 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(NEW.field_6 ,''))>0 THEN SET vChangeUser = 00000; END IF; END ;; CREATE TRIGGER table_b_before_update BEFORE UPDATE ON table_b FOR EACH ROW this_proc: BEGIN DECLARE vChange TEXT DEFAULT ''; DECLARE vChangeUser TEXT DEFAULT 'NONE'; IF CHAR_LENGTH(IFNULL(@audit_triggers_disabled,''))>0 THEN LEAVE this_proc; END IF; IF CHAR_LENGTH(IFNULL(@audit_username,''))>0 THEN SET vChangeUser = @audit_username; END IF; SET vChange = CONCAT(NEW.id,NEW.field_2 ,NEW.field_3 ,NEW.field_4 ,NEW.field_5 ,NEW.field_6); SET vChangeUser = 00000; IF CHAR_LENGTH(IFNULL(OLD.field_2 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_2 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_3 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_4 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_5 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_6 ,''))>0 THEN SET vChangeUser = 00000; END IF; END ;; CREATE TRIGGER table_b_before_delete BEFORE DELETE ON table_b FOR EACH ROW this_proc: BEGIN DECLARE vChange TEXT DEFAULT ''; DECLARE vChangeUser TEXT DEFAULT 'NONE'; IF CHAR_LENGTH(IFNULL(@audit_triggers_disabled,''))>0 THEN LEAVE this_proc; END IF; IF CHAR_LENGTH(IFNULL(@audit_username,''))>0 THEN SET vChangeUser = @audit_username; END IF; SET vChange = CONCAT(OLD.id,OLD.field_2 ,OLD.field_3 ,OLD.field_4 ,OLD.field_5 ,OLD.field_6); IF CHAR_LENGTH(IFNULL(OLD.field_2 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_2 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_3 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_4 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_5 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_6 ,''))>0 THEN SET vChangeUser = 00000; END IF; END ;; /*** table_c ***/ CREATE TRIGGER table_c_before_insert BEFORE INSERT ON table_c FOR EACH ROW this_proc: BEGIN DECLARE vChange TEXT DEFAULT ''; DECLARE vChangeUser TEXT DEFAULT 'NONE'; IF CHAR_LENGTH(IFNULL(@audit_triggers_disabled,''))>0 THEN LEAVE this_proc; END IF; IF CHAR_LENGTH(IFNULL(@audit_username,''))>0 THEN SET vChangeUser = @audit_username; END IF; SET vChange = CONCAT(NEW.id,NEW.field_2 ,NEW.field_3 ,NEW.field_4 ,NEW.field_5 ,NEW.field_6); IF CHAR_LENGTH(IFNULL(NEW.field_2 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(NEW.field_2 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(NEW.field_3 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(NEW.field_4 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(NEW.field_5 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(NEW.field_6 ,''))>0 THEN SET vChangeUser = 00000; END IF; END ;; CREATE TRIGGER table_c_before_update BEFORE UPDATE ON table_c FOR EACH ROW this_proc: BEGIN DECLARE vChange TEXT DEFAULT ''; DECLARE vChangeUser TEXT DEFAULT 'NONE'; IF CHAR_LENGTH(IFNULL(@audit_triggers_disabled,''))>0 THEN LEAVE this_proc; END IF; IF CHAR_LENGTH(IFNULL(@audit_username,''))>0 THEN SET vChangeUser = @audit_username; END IF; SET vChange = CONCAT(NEW.id,NEW.field_2 ,NEW.field_3 ,NEW.field_4 ,NEW.field_5 ,NEW.field_6); IF CHAR_LENGTH(IFNULL(OLD.field_2 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_2 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_3 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_4 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_5 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_6 ,''))>0 THEN SET vChangeUser = 00000; END IF; END ;; CREATE TRIGGER table_c_before_delete BEFORE DELETE ON table_c FOR EACH ROW this_proc: BEGIN DECLARE vChange TEXT DEFAULT ''; DECLARE vChangeUser TEXT DEFAULT 'NONE'; IF CHAR_LENGTH(IFNULL(@audit_triggers_disabled,''))>0 THEN LEAVE this_proc; END IF; IF CHAR_LENGTH(IFNULL(@audit_username,''))>0 THEN SET vChangeUser = @audit_username; END IF; SET vChange = CONCAT(OLD.id,OLD.field_2 ,OLD.field_3 ,OLD.field_4 ,OLD.field_5 ,OLD.field_6); IF CHAR_LENGTH(IFNULL(OLD.field_2 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_2 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_3 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_4 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_5 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_6 ,''))>0 THEN SET vChangeUser = 00000; END IF; END ;; /*** table_d ***/ CREATE TRIGGER table_d_before_insert BEFORE INSERT ON table_d FOR EACH ROW this_proc: BEGIN DECLARE vChange TEXT DEFAULT ''; DECLARE vChangeUser TEXT DEFAULT 'NONE'; IF CHAR_LENGTH(IFNULL(@audit_triggers_disabled,''))>0 THEN LEAVE this_proc; END IF; IF CHAR_LENGTH(IFNULL(@audit_username,''))>0 THEN SET vChangeUser = @audit_username; END IF; SET vChange = CONCAT(NEW.id,NEW.field_2 ,NEW.field_3 ,NEW.field_4 ,NEW.field_5 ,NEW.field_6); IF CHAR_LENGTH(IFNULL(NEW.field_2 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(NEW.field_2 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(NEW.field_3 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(NEW.field_4 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(NEW.field_5 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(NEW.field_6 ,''))>0 THEN SET vChangeUser = 00000; END IF; END ;; CREATE TRIGGER table_d_before_update BEFORE UPDATE ON table_d FOR EACH ROW this_proc: BEGIN DECLARE vChange TEXT DEFAULT ''; DECLARE vChangeUser TEXT DEFAULT 'NONE'; IF CHAR_LENGTH(IFNULL(@audit_triggers_disabled,''))>0 THEN LEAVE this_proc; END IF; IF CHAR_LENGTH(IFNULL(@audit_username,''))>0 THEN SET vChangeUser = @audit_username; END IF; SET vChange = CONCAT(NEW.id,NEW.field_2 ,NEW.field_3 ,NEW.field_4 ,NEW.field_5 ,NEW.field_6); IF CHAR_LENGTH(IFNULL(OLD.field_2 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_2 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_3 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_4 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_5 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_6 ,''))>0 THEN SET vChangeUser = 00000; END IF; END ;; CREATE TRIGGER table_d_before_delete BEFORE DELETE ON table_d FOR EACH ROW this_proc: BEGIN DECLARE vChange TEXT DEFAULT ''; DECLARE vChangeUser TEXT DEFAULT 'NONE'; IF CHAR_LENGTH(IFNULL(@audit_triggers_disabled,''))>0 THEN LEAVE this_proc; END IF; IF CHAR_LENGTH(IFNULL(@audit_username,''))>0 THEN SET vChangeUser = @audit_username; END IF; SET vChange = CONCAT(OLD.id,OLD.field_2 ,OLD.field_3 ,OLD.field_4 ,OLD.field_5 ,OLD.field_6); IF CHAR_LENGTH(IFNULL(OLD.field_2 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_2 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_3 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_4 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_5 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_6 ,''))>0 THEN SET vChangeUser = 00000; END IF; END ;; CREATE TRIGGER table_b_after_insert BEFORE INSERT ON table_b FOR EACH ROW this_proc: BEGIN DECLARE vChange TEXT DEFAULT ''; DECLARE vChangeUser TEXT DEFAULT 'NONE'; IF CHAR_LENGTH(IFNULL(@audit_triggers_disabled,''))>0 THEN LEAVE this_proc; END IF; IF CHAR_LENGTH(IFNULL(@audit_username,''))>0 THEN SET vChangeUser = @audit_username; END IF; SET vChange = CONCAT(NEW.id,NEW.field_2 ,NEW.field_3 ,NEW.field_4 ,NEW.field_5 ,NEW.field_6); IF CHAR_LENGTH(IFNULL(NEW.field_2 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(NEW.field_2 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(NEW.field_3 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(NEW.field_4 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(NEW.field_5 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(NEW.field_6 ,''))>0 THEN SET vChangeUser = 00000; END IF; END ;; CREATE TRIGGER table_b_after_update BEFORE UPDATE ON table_b FOR EACH ROW this_proc: BEGIN DECLARE vChange TEXT DEFAULT ''; DECLARE vChangeUser TEXT DEFAULT 'NONE'; IF CHAR_LENGTH(IFNULL(@audit_triggers_disabled,''))>0 THEN LEAVE this_proc; END IF; IF CHAR_LENGTH(IFNULL(@audit_username,''))>0 THEN SET vChangeUser = @audit_username; END IF; SET vChange = CONCAT(NEW.id,NEW.field_2 ,NEW.field_3 ,NEW.field_4 ,NEW.field_5 ,NEW.field_6); IF CHAR_LENGTH(IFNULL(OLD.field_2 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_2 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_3 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_4 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_5 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_6 ,''))>0 THEN SET vChangeUser = 00000; END IF; END ;; CREATE TRIGGER table_b_after_delete BEFORE DELETE ON table_b FOR EACH ROW this_proc: BEGIN DECLARE vChange TEXT DEFAULT ''; DECLARE vChangeUser TEXT DEFAULT 'NONE'; IF CHAR_LENGTH(IFNULL(@audit_triggers_disabled,''))>0 THEN LEAVE this_proc; END IF; IF CHAR_LENGTH(IFNULL(@audit_username,''))>0 THEN SET vChangeUser = @audit_username; END IF; SET vChange = CONCAT(OLD.id,OLD.field_2 ,OLD.field_3 ,OLD.field_4 ,OLD.field_5 ,OLD.field_6); IF CHAR_LENGTH(IFNULL(OLD.field_2 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_2 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_3 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_4 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_5 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_6 ,''))>0 THEN SET vChangeUser = 00000; END IF; END ;; /*** table_c ***/ CREATE TRIGGER table_c_after_insert BEFORE INSERT ON table_c FOR EACH ROW this_proc: BEGIN DECLARE vChange TEXT DEFAULT ''; DECLARE vChangeUser TEXT DEFAULT 'NONE'; IF CHAR_LENGTH(IFNULL(@audit_triggers_disabled,''))>0 THEN LEAVE this_proc; END IF; IF CHAR_LENGTH(IFNULL(@audit_username,''))>0 THEN SET vChangeUser = @audit_username; END IF; SET vChange = CONCAT(NEW.id,NEW.field_2 ,NEW.field_3 ,NEW.field_4 ,NEW.field_5 ,NEW.field_6); IF CHAR_LENGTH(IFNULL(NEW.field_2 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(NEW.field_2 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(NEW.field_3 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(NEW.field_4 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(NEW.field_5 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(NEW.field_6 ,''))>0 THEN SET vChangeUser = 00000; END IF; END ;; CREATE TRIGGER table_c_after_update BEFORE UPDATE ON table_c FOR EACH ROW this_proc: BEGIN DECLARE vChange TEXT DEFAULT ''; DECLARE vChangeUser TEXT DEFAULT 'NONE'; IF CHAR_LENGTH(IFNULL(@audit_triggers_disabled,''))>0 THEN LEAVE this_proc; END IF; IF CHAR_LENGTH(IFNULL(@audit_username,''))>0 THEN SET vChangeUser = @audit_username; END IF; SET vChange = CONCAT(NEW.id,NEW.field_2 ,NEW.field_3 ,NEW.field_4 ,NEW.field_5 ,NEW.field_6); IF CHAR_LENGTH(IFNULL(OLD.field_2 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_2 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_3 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_4 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_5 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_6 ,''))>0 THEN SET vChangeUser = 00000; END IF; END ;; CREATE TRIGGER table_c_after_delete BEFORE DELETE ON table_c FOR EACH ROW this_proc: BEGIN DECLARE vChange TEXT DEFAULT ''; DECLARE vChangeUser TEXT DEFAULT 'NONE'; IF CHAR_LENGTH(IFNULL(@audit_triggers_disabled,''))>0 THEN LEAVE this_proc; END IF; IF CHAR_LENGTH(IFNULL(@audit_username,''))>0 THEN SET vChangeUser = @audit_username; END IF; SET vChange = CONCAT(OLD.id,OLD.field_2 ,OLD.field_3 ,OLD.field_4 ,OLD.field_5 ,OLD.field_6); IF CHAR_LENGTH(IFNULL(OLD.field_2 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_2 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_3 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_4 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_5 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_6 ,''))>0 THEN SET vChangeUser = 00000; END IF; END ;; /*** table_d ***/ CREATE TRIGGER table_d_after_insert BEFORE INSERT ON table_d FOR EACH ROW this_proc: BEGIN DECLARE vChange TEXT DEFAULT ''; DECLARE vChangeUser TEXT DEFAULT 'NONE'; IF CHAR_LENGTH(IFNULL(@audit_triggers_disabled,''))>0 THEN LEAVE this_proc; END IF; IF CHAR_LENGTH(IFNULL(@audit_username,''))>0 THEN SET vChangeUser = @audit_username; END IF; SET vChange = CONCAT(NEW.id,NEW.field_2 ,NEW.field_3 ,NEW.field_4 ,NEW.field_5 ,NEW.field_6); IF CHAR_LENGTH(IFNULL(NEW.field_2 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(NEW.field_2 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(NEW.field_3 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(NEW.field_4 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(NEW.field_5 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(NEW.field_6 ,''))>0 THEN SET vChangeUser = 00000; END IF; END ;; CREATE TRIGGER table_d_after_update BEFORE UPDATE ON table_d FOR EACH ROW this_proc: BEGIN DECLARE vChange TEXT DEFAULT ''; DECLARE vChangeUser TEXT DEFAULT 'NONE'; IF CHAR_LENGTH(IFNULL(@audit_triggers_disabled,''))>0 THEN LEAVE this_proc; END IF; IF CHAR_LENGTH(IFNULL(@audit_username,''))>0 THEN SET vChangeUser = @audit_username; END IF; SET vChange = CONCAT(NEW.id,NEW.field_2 ,NEW.field_3 ,NEW.field_4 ,NEW.field_5 ,NEW.field_6); IF CHAR_LENGTH(IFNULL(OLD.field_2 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_2 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_3 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_4 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_5 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_6 ,''))>0 THEN SET vChangeUser = 00000; END IF; END ;; CREATE TRIGGER table_d_after_delete BEFORE DELETE ON table_d FOR EACH ROW this_proc: BEGIN DECLARE vChange TEXT DEFAULT ''; DECLARE vChangeUser TEXT DEFAULT 'NONE'; IF CHAR_LENGTH(IFNULL(@audit_triggers_disabled,''))>0 THEN LEAVE this_proc; END IF; IF CHAR_LENGTH(IFNULL(@audit_username,''))>0 THEN SET vChangeUser = @audit_username; END IF; SET vChange = CONCAT(OLD.id,OLD.field_2 ,OLD.field_3 ,OLD.field_4 ,OLD.field_5 ,OLD.field_6); IF CHAR_LENGTH(IFNULL(OLD.field_2 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_2 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_3 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_4 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_5 ,''))>0 THEN SET vChangeUser = 00000; END IF; IF CHAR_LENGTH(IFNULL(OLD.field_6 ,''))>0 THEN SET vChangeUser = 00000; END IF; END ;; DELIMITER ;