It seems something is wrong with my procedure. When I execute it, it should create an entry, directly modify a column and then return the id of it.
But nothing is created and it also returns nothing (not even an error is shown)
When I use hard coded values instead of using the parameters, the entry is created, but not edited and the ID is still not returned.
Could you guys have a look over it? This is the whole procedure result using the export function of phpMyAdmin:
CREATE DEFINER=`dbuser`@`localhost` PROCEDURE `createRecruitment`(IN `p_user_id` INT(11), IN `p_platform` ENUM('uplay','steam','ps4','xb1') CHARSET utf8, IN `p_activity` ENUM('pve','pvp') CHARSET utf8, IN `p_description` TEXT CHARSET utf8)
MODIFIES SQL DATA
DETERMINISTIC
SQL SECURITY INVOKER
BEGIN
DECLARE v_id INT(11);
INSERT INTO
recruitments (
user_id,
creationDate,
platform_id,
activity,
description
)
SELECT
p_user_id,
CURRENT_TIMESTAMP,
platforms.id,
p_activity,
p_description
FROM
platforms
WHERE
platforms.platform = p_platform;
SET v_id = LAST_INSERTED_ID();
UPDATE
recruitments
SET
lastActivity = creationDate
WHERE
id = v_id;
SELECT v_id;
END
EDIT
It seems the main problem is the "p_platform" parameter. I wanted to limit the input to the given ENUM but it seems the WHERE platforms.platform = p_platform doesn't work proper with this.