All Things Techie With Huge, Unstructured, Intuitive Leaps

Calling A MySQL Stored Procedure From The Command Line With Output Parameters

I had a junior programmer ask me how to do stored procedure calls from the MySQL command line that had output parameters.  It had stumped him, and he had no other choice but to use the command line instead of a GUI tool, because he was working remotely on a Linux server.

Here is how to do it.  Suppose that the stored procedure has two input parameters and two output parameters.  Here is the syntax:

call doStoredProcedure('param1', 'param2', @t, @s);
select @t, @s;

The second line retrieves the output of the stored procedure.

Hope this helps someone.

No comments:

Post a Comment