DELIMITER $$
CREATE PROCEDURE `newsletterProcedure`(IN `email` VARCHAR(255), IN `subscriptionType` VARCHAR(255))
BEGIN
    DECLARE tempCount INT;
    DECLARE generatedUUID VARCHAR(36);
    SET generatedUUID = UUID();
    SET tempCount = 0;
    SELECT COUNT(*) INTO tempCount FROM newsletter WHERE email = email;
    
    IF tempCount > 0 THEN
        UPDATE newsletter
        SET subscriptionType = subscriptionType
        WHERE email = email;
    ELSE
        INSERT INTO newsletter(id, email, subscriptionType) 
        VALUES(generatedUUID, email, subscriptionType);
    END IF;
END$$
DELIMITER ;