pub fn execute_call(
stmt: &CallStmt,
db: &mut Database,
) -> Result<(), ExecutorError>Expand description
Execute CALL statement (SQL:1999 Feature P001)
Executes a stored procedure with parameter binding and procedural statement execution.
§Parameter Binding
- IN parameters: Values are evaluated and passed to the procedure
- OUT parameters: Must be session variables (@var), initialized to NULL, procedure can assign values that are returned to caller
- INOUT parameters: Must be session variables (@var), values are passed in and can be modified by the procedure
§Example
-- Create procedure with mixed parameter modes
CREATE PROCEDURE update_counter(
IN increment INT,
INOUT counter INT,
OUT message VARCHAR(100)
)
BEGIN
SET counter = counter + increment;
SET message = CONCAT('Counter updated to ', counter);
END;
-- Call procedure
SET @count = 10;
CALL update_counter(5, @count, @msg);
SELECT @count, @msg;
-- Output: count=15, msg='Counter updated to 15'§Control Flow
The procedure body executes sequentially until:
- All statements complete (normal exit)
- RETURN statement is encountered (early exit)
- Error occurs (execution stops)
After execution, OUT and INOUT parameter values are written back to their corresponding session variables.
§Errors
Returns error if:
- Procedure not found
- Wrong number of arguments
- OUT/INOUT parameter is not a session variable
- Type mismatch in parameter binding
- Execution error in procedure body