mysql触发器 if条件判断

下面是一段带条件判断的触发器

CREATE TRIGGER `check_users` BEFORE INSERT ON `mk_mm_marketparticipant`
FOR EACH ROW
BEGIN
    IF NEW.exchange_code = '02' THEN
        	insert into mk_td_base_participant_02(
						participant_id,
						participant_name,
						participant_short_name,
						participant_type,
						participant_code,
						exchange_code,
						file_type,
						file_sync_time
					) values (NEW.participant_id, NEW.participant_name, NEW.participant_short_name, NEW.participant_type, NEW.participant_code, NEW.exchange_code, '01', DATE_FORMAT(NOW(), '%Y-%m-%d'));

    END IF;

    IF NEW.exchange_code = '03' THEN
        	insert into mk_td_base_participant_03(
						participant_id,
						participant_name,
						participant_short_name,
						participant_type,
						participant_code,
						exchange_code,
						file_type,
						file_sync_time
					) values (NEW.participant_id, NEW.participant_name, NEW.participant_short_name, NEW.participant_type, NEW.participant_code, NEW.exchange_code, '01', DATE_FORMAT(NOW(), '%Y-%m-%d'));

    END IF;
	
	IF NEW.exchange_code = '04' THEN
        	insert into mk_td_base_participant_04(
						participant_id,
						participant_name,
						participant_short_name,
						participant_type,
						participant_code,
						exchange_code,
						file_type,
						file_sync_time
					) values (NEW.participant_id, NEW.participant_name, NEW.participant_short_name, NEW.participant_type, NEW.participant_code, NEW.exchange_code, '01', DATE_FORMAT(NOW(), '%Y-%m-%d'));

    END IF;
	
	
END;

你可能感兴趣的:(mysql,数据库)