/* GET THE ID OF AN EMAIL TEMPLATE */
/* =============================================================================================================== */
DROP FUNCTION IF EXISTS GET_EMAIL_TEMPLATE;
COMMIT;

DELIMITER //

CREATE FUNCTION `GET_EMAIL_TEMPLATE`(`p_emailName` VARCHAR(100))
RETURNS INT
BEGIN

  DECLARE iTemplateId INT;

  SELECT `_id` 
  FROM `EmailTemplates`
  WHERE `name` = p_emailName
  INTO iTemplateId;
	
	RETURN iTemplateId;

END 
//
COMMIT //

DELIMITER ;
