
==>mj_msg_data 에 문자가 들어가면 agent msg_data 에 넘겨주는 트리거
CREATE DEFINER=`mjonUr`@`%` TRIGGER `Trg_mjMsgDataInsertToIheart`
AFTER INSERT ON `mj_msg_data`
FOR EACH ROW
BEGIN
 /** (NPRO)아이하트 */
 IF NEW.AGENT_CODE='01' THEN
	CASE NEW.MSG_TYPE
	WHEN '4' THEN /** 문자타입 4:SMS */
		INSERT INTO MSG_DATA
		(USERDATA,
		CUR_STATE,
		REQ_DATE,
		CALL_TO,
		CALL_FROM,
		SMS_TXT,
		MSG_TYPE,
		CONT_SEQ
		)
		VALUES (
		NEW.USERDATA,
		NEW.CUR_STATE,
		NEW.REQ_DATE,
		NEW.CALL_TO,
		NEW.CALL_FROM,
		NEW.SMS_TXT,
		NEW.MSG_TYPE,
		NEW.CONT_SEQ
		);
	WHEN '6' THEN  /** 문자타입 6: MMS */
		INSERT INTO MSG_DATA
		(USERDATA,
		CUR_STATE,
		REQ_DATE,
		CALL_TO,
		CALL_FROM,
		MSG_TYPE,
		CONT_SEQ
		)
		VALUES (
		NEW.USERDATA,
		NEW.CUR_STATE,
		NEW.REQ_DATE,
		NEW.CALL_TO,
		NEW.CALL_FROM,
		NEW.MSG_TYPE,
		NEW.CONT_SEQ
		);
	END CASE;

 END IF;
END

==>mms_log 에 agent를 통한 결과값이 들어오면 mj_msg_data에 update 시켜주는 트리거
CREATE DEFINER=`mjonUr`@`%` TRIGGER `mjon`.`Trg_HncMmsLogInsert`
AFTER INSERT ON `mms_log`
FOR EACH ROW
BEGIN
	UPDATE MJ_MSG_DATA SET 
		MSG_SEQ = NEW.MSGKEY , 
		SENT_DATE = NEW.REPORTDATE ,
		REPORT_DATE = NEW.REPORTDATE ,
		RSLT_DATE = NEW.RSLTDATE ,  
		RSLT_CODE = NEW.RSLT ,  
		RSLT_NET = NEW.TELCOINFO,   
		CUR_STATE = NEW.STATUS,
		RESULT_LOG_UPDT_PNTTM = NOW()
	WHERE USERDATA = NEW.ID;  
END
