When I INSERT a User who is already in the Database, then the RETURN "Error_UsernameExist" should trigger but instead I get following Error message from the function: Error Code: 1062. Duplicate entry 'testUser' for key 'Username_UNIQUE'
following function:
CREATE FUNCTION `registration`(usernameP TEXT, passwordP TEXT, saltP BLOB) RETURNS TEXT
BEGIN
IF ((SELECT `Username` FROM `DEV`.`RUser` WHERE `Username` = usernameP) = 1) THEN
RETURN "Error_UsernameExist";
END IF;
INSERT INTO `DEV`.`RUser` (`Username`, `Password`, `Salt`) VALUES (usernameP, passwordP, saltP);
RETURN "OK";
END