I have a procedure in MySQL and I want the string Question_Description to be passed as an OUT parameter. However, every time I execute the procedure, it always returns NULL. How do I fix this? I have tried many different methods and none of them have worked.
DELIMITER $$
CREATE PROCEDURE `QuestionTitle`(IN `QID` INT(11), OUT `Description` VARCHAR(255))
BEGIN
select Question.Question_ID, Question.Question_Description
FROM Question, QuestionAllocator
WHERE Question.Question_ID=QuestionAllocator.QuestionID and Question.Question_ID=QID;
END$$
DELIMITER ;
You need to assign a value.
CREATE PROCEDURE `QuestionTitle`(
IN in_QID INT(11),
OUT out_Description VARCHAR(255)
)
BEGIN
SELECT out_Description := q.Question_Description
FROM Question q
WHERE q.Question_ID = in_QID;
END$$
Note the other changes:
JOIN
syntax, even if this query does not require a JOIN
.