I have to convert a MSSQL stored proc that passes a varchar
that is a query:
INSERT INTO Results
EXEC (@Expresion);
This isn't working. I'm pretty sure that EXEC
and EXECUTE
aren't MySQL commands, but CALL
doesn't work either.
Does anyone know if it's even possible to have something like JavaScript's eval
function for MySQL?
EXECUTE is a valid command in MySQL. MySQL reference manual
The
EXECUTE
MySQL command can only be used for one prepared statement.If case you want to execute multiple queries from the string, consider saving them into file and source it, e.g.
I think you're looking for something like this:
This is the SQL equivalent of
eval(my_string);
:Basically I combined the existing answers, neither tells you how to do eval exactly.
If you want to add parameters, you can use this:
And to answer the original question exactly:
Note that the
PREPARE ... FROM
statement wants a session variable (prefixed with@
). If you try to pass a normal variable, it will throw its hands up in the air and it just won't care.