CREATE DEFINER=`aerion`@`192.180.1.5` TRIGGER `comp_active_after_insert` AFTER INSERT ON `comp_active` FOR EACH ROW begin INSERT INTO log_global set last_update = now(), updater = (select concat(firstname,' ',lastname) as name from emp where emp_id=(case when (NEW.updater = 0) then 1 else NEW.updater end)), table_update = 'comp_active', actions = 'A', table_id = CONCAT('comp_act_id', '.',NEW.idcomp_active), col1 = CONCAT('comp_name','.',(select companyname from company where comp_id=NEW.comp_id)), col4 = CONCAT('comp_background', '.',NEW.comp_background), col5 = CONCAT('active_type', '.',NEW.active_type), col7 = CONCAT('publish', '.',NEW.publish), col8 = CONCAT('manage_by', '.',(select concat(firstname, ' ',lastname) from emp where emp_id = NEW.manage_by)), col10 = CONCAT('emp_name', '.',(select concat(firstname, ' ',lastname) from emp where emp_id = NEW.emp_id)), col13 = CONCAT('client_since', '.',date_format(NEW.client_since,'%m-%d-%y')); END CREATE DEFINER=`aerion`@`192.180.1.5` TRIGGER `comp_active_after_update` AFTER UPDATE ON `comp_active` FOR EACH ROW begin INSERT INTO log_global set last_update = now(), updater = (select concat(firstname,' ',lastname) as name from emp where emp_id=(case when (OLD.updater = 0) then 1 else OLD.updater end)), table_update = 'comp_active', actions = 'O', table_id = CONCAT('comp_act_id', '.',OLD.idcomp_active), col1 = CONCAT('comp_name','.',(select companyname from company where comp_id=OLD.comp_id)), col4 = CONCAT('comp_background', '.',OLD.comp_background), col5 = CONCAT('active_type', '.',OLD.active_type), col7 = CONCAT('publish', '.',OLD.publish), col8 = CONCAT('manage_by', '.',(select concat(firstname, ' ',lastname) from emp where emp_id = OLD.manage_by)), col10 = CONCAT('emp_name', '.',(select concat(firstname, ' ',lastname) from emp where emp_id = OLD.emp_id)), col13 = CONCAT('client_since', '.',date_format(OLD.client_since,'%m-%d-%y')); INSERT INTO log_global set last_update = now(), updater = (select concat(firstname,' ',lastname) as name from emp where emp_id=(case when (NEW.updater = 0) then 1 else NEW.updater end)), table_update = 'comp_active', actions = 'N', table_id = CONCAT('comp_act_id', '.',NEW.idcomp_active), col1 = CONCAT('comp_name','.',(select companyname from company where comp_id=NEW.comp_id)), col4 = CONCAT('comp_background', '.',NEW.comp_background), col5 = CONCAT('active_type', '.',NEW.active_type), col7 = CONCAT('publish', '.',NEW.publish), col8 = CONCAT('manage_by', '.',(select concat(firstname, ' ',lastname) from emp where emp_id = NEW.manage_by)), col10 = CONCAT('emp_name', '.',(select concat(firstname, ' ',lastname) from emp where emp_id = NEW.emp_id)), col13 = CONCAT('client_since', '.',date_format(NEW.client_since,'%m-%d-%y')); END CREATE DEFINER=`aerion`@`192.180.1.5` TRIGGER `comp_active_after_delete` AFTER DELETE ON `comp_active` FOR EACH ROW begin INSERT INTO log_global set last_update = now(), updater = (select concat(firstname,' ',lastname) as name from emp where emp_id=(case when (OLD.updater = 0) then 1 else OLD.updater end)), table_update = 'comp_active', actions = 'D', table_id = CONCAT('comp_act_id', '.',OLD.idcomp_active), col1 = CONCAT('comp_name','.',(select companyname from company where comp_id=OLD.comp_id)), col4 = CONCAT('comp_background', '.',OLD.comp_background), col5 = CONCAT('active_type', '.',OLD.active_type), col7 = CONCAT('publish', '.',OLD.publish), col8 = CONCAT('manage_by', '.',(select concat(firstname, ' ',lastname) from emp where emp_id = OLD.manage_by)), col10 = CONCAT('emp_name', '.',(select concat(firstname, ' ',lastname) from emp where emp_id = OLD.emp_id)), col13 = CONCAT('client_since', '.',date_format(OLD.client_since,'%m-%d-%y')); END