Assume we have a stored procedure like so
CREATE PROCEDURE CopyValue(IN src INT, OUT dest INT)
BEGIN
SET dest = src;
END
I want to call this from a .net app (assume connection etc created successfully)
var sql = "call CopyValue(100, @destValue); select @destValue as Results;";
The string in the above statement works perfectly well when called in MySql Workbench.
However this - obviously - fails with "MySqlException: Parameter '@destValue' must be defined" when executed on a MySqlCommand
object in .net
How do I arrange this statement so I can capture an output parameter from an existing procedure?
NB: I'm running against MySql 5.6, which I can't upgrade at this time.
NB Calling the procedure directly with CommandType.StoredProcedure
goes against company guidelines.
A colleague (who wishes to remain anonymous) has answered this perfectly. Essentially put backticks ` after the @ and at the end of the variable name e.g.
A fully working example.
Thanks OG :)