CALLsp_name([parameter[,...]]) CALLsp_name[()]
The CALL statement invokes a procedure that
was defined previously with CREATE PROCEDURE.
CALL can pass back values to its caller using
parameters that are declared as OUT or
INOUT parameters. It also
“returns” the number of rows affected, which a
client program can obtain at the SQL level by calling the
ROW_COUNT() function and from C by calling
the mysql_affected_rows() C API function.
As of MySQL 5.1.13, stored procedures that take no arguments now
can be invoked without parentheses. That is, CALL
p() and CALL p are equivalent.
To get back a value from a procedure using an
OUT or INOUT parameter,
pass the parameter by means of a user variable, and then check
the value of the variable after the procedure returns. (If you
are calling the procedure from within another stored procedure
or function, you can also pass a routine parameter or local
routine variable as an IN or
INOUT parameter.) For an
INOUT parameter, initialize its value before
passing it to the procedure. The following procedure has an
OUT parameter that the procedure sets to the
current server version, and an INOUT value
that the procedure increments by one from its current value:
CREATE PROCEDURE p (OUT ver_param VARCHAR(25), INOUT incr_param INT) BEGIN # Set value of OUT parameter SELECT VERSION() INTO ver_param; # Increment value of INOUT parameter SET incr_param = incr_param + 1; END;
Before calling the procedure, initialize the variable to be
passed as the INOUT parameter. After calling
the procedure, the values of the two variables will have been
set or modified:
mysql>SET @increment = 10;mysql>CALL p(@version, @increment);mysql>SELECT @version, @increment;+------------+------------+ | @version | @increment | +------------+------------+ | 5.0.25-log | 11 | +------------+------------+
If you write C programs that execute stored procedures with the
CALL SQL statement, you
must set the
CLIENT_MULTI_RESULTS flag when you call
mysql_real_connect(), either explicitly, or
implicitly by setting
CLIENT_MULTI_STATEMENTS. This is because each
CALL returns a result to indicate the call
status, in addition to any results sets that might be returned
by statements executed within the procedure. To process the
result of a CALL statement, use a loop that
calls mysql_next_result() to determine
whether there are more results. For an example, see
Section 22.2.9, “C API Handling of Multiple Statement Execution”.

User Comments
Example:
DELIMITER $
create procedure spMySproc(IN iParamOne INT, IN iParamTwo INT)
begin
/* do stuff */
end$
DELIMITER ;
call spMySproc(1,1);
Add your own comment.