CREATE DEFINER=`aerion`@`192.180.1.5` TRIGGER `emp_contact_after_insert` AFTER INSERT ON `emp_contact` FOR EACH ROW begin DECLARE vUser varchar(50); IF(NEW.updater='0')THEN set vUser='Admin'; else set vUser=(select concat(firstname, ' ',lastname) from emp where emp_id = NEW.updater); END IF; INSERT INTO log_global set last_update = now(), updater = vUser, table_update = 'emp_contact', actions = 'A', table_id = CONCAT('emp_contact_id', '.',NEW.emp_contact_id), col1 = CONCAT('emp_name', '.',(select concat(firstname,' ',lastname) as name from emp where emp_id=NEW.emp_id)), col4 = CONCAT('contact_detail', '.',(select contact_detail from contact_no where contact_id=NEW.contact_id)), col7 = CONCAT('emp_contact_type', '.',(select look_values from look_values where look_values_id=NEW.emp_contact_type)), col10 = CONCAT('Summary', '.',NEW.summary); END CREATE DEFINER=`aerion`@`192.180.1.5` TRIGGER `emp_contact_after_update` AFTER UPDATE ON `emp_contact` 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 = 'emp_contact', actions = 'O', table_id = CONCAT('emp_contact_id', '.',OLD.emp_contact_id), col1 = CONCAT('emp_name', '.',(select concat(firstname,' ',lastname) as name from emp where emp_id=OLD.emp_id)), col4 = CONCAT('contact_detail', '.',(select contact_detail from contact_no where contact_id=OLD.contact_id)), col7 = CONCAT('emp_contact_type', '.',(select look_values from look_values where look_values_id=OLD.emp_contact_type)), col10 = CONCAT('Summary', '.',OLD.summary); 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 = 'emp_contact', actions = 'N', table_id = CONCAT('emp_contact_id', '.',NEW.emp_contact_id), col1 = CONCAT('emp_name', '.',(select concat(firstname,' ',lastname) as name from emp where emp_id=NEW.emp_id)), col4 = CONCAT('contact_detail', '.',(select contact_detail from contact_no where contact_id=NEW.contact_id)), col7 = CONCAT('emp_contact_type', '.',(select look_values from look_values where look_values_id=NEW.emp_contact_type)), col10 = CONCAT('Summary', '.',NEW.summary); END CREATE DEFINER=`aerion`@`192.180.1.5` TRIGGER `emp_contact_after_delete` AFTER DELETE ON `emp_contact` FOR EACH ROW begin DECLARE vUser varchar(50); IF(OLD.updater='0')THEN set vUser='Admin'; else set vUser=(select concat(firstname, ' ',lastname) from emp where emp_id = OLD.updater); END IF; INSERT INTO log_global set last_update = now(), updater = vUser, table_update = 'emp_contact', actions = 'D', table_id = CONCAT('emp_contact_id', '.',OLD.emp_contact_id), col1 = CONCAT('emp_name', '.',(select concat(firstname,' ',lastname) as name from emp where emp_id=OLD.emp_id)), col4 = CONCAT('contact_detail', '.',(select contact_detail from contact_no where contact_id=OLD.contact_id)), col7 = CONCAT('emp_contact_type', '.',(select look_values from look_values where look_values_id=OLD.emp_contact_type)), col10 = CONCAT('Summary', '.',OLD.summary); END