I created a stored procedure which requirement as below
When I execute the stored procedure with one username typed in which be compare if username are exists in database then (variable) result_userId will set at userId ELSE if username dose not exists in database then (variable) result_userId will be set the number 99
BUT I CANNOT DO THAT
Please help me !
::CODE BELOW::
DELIMITER $$
USE `shoppy` $$
CREATE PROCEDURE `testProc02`
(
    IN  _username  CHAR(50),
    OUT result_userId   INT UNSIGNED
)
BEGIN
    SELECT @uId := userId FROM user 
    WHERE userName = _username;
    IF @uId = NULL THEN
        SET result_userId = 99;
    ELSE
        SET result_userId = @uId;
    END IF;    
END $$
DELIMITER ;
When I CALL testProc02();