I am writing a stored procedure in MySQL. The following is the code I wrote:
SET @qry = 'SELECT id into @wid FROM work_profile where candidate_id = 1223 limit 1';
PREPARE statement FROM @qry;
EXECUTE statement;
However, @wid
is null after execution.
SELECT id FROM work_profile where candidate_id = 1223 limit 1
This returns a value of 1443.
Best Answer
The following works for me:
And to call the procedure:
However, this does not seem to work in the MySQL Query Browser. I had to resort to using the MySQL command line client. I suspect the Query Browser clears the session after each statement.
For more EXECUTE examples, see the MySQL manual: