hedera-web/rest/edi/dml/message_new.sql

28 lines
532 B
MySQL
Raw Normal View History

/**
* Registers an email.
*
* @param v_mail_id Message-ID of email
* @param v_sender Origin email id
2016-12-20 09:32:17 +00:00
*/
USE edi;
DROP PROCEDURE IF EXISTS message_new;
DELIMITER $$
CREATE PROCEDURE message_new (
v_mail_id VARCHAR(100)
,v_sender VARCHAR(150)
,OUT v_message_id INT
)
BEGIN
DECLARE v_sender_id INT;
SELECT id INTO v_sender_id FROM mail
WHERE mail = v_sender;
INSERT IGNORE INTO message SET
sender_id = v_sender_id
,mail_id = v_mail_id;
SET v_message_id = LAST_INSERT_ID();
END$$
DELIMITER ;