Defining procedures or functions is a two-step process:
Define the name of the procedure or function, and set its parameters.
Define the body of the procedure or function between BEGIN and END statements.
Here’s the basic syntax:
CREATE PROCEDURE procedure_name ([procedure_parameter[,…]])
routine_body
The procedure_parameter is a list of parameters and their directions, composed using the following arguments:
IN: Passes a value into a procedure. The procedure can modify the value, but the modification is not visible to the caller when the procedure returns.
OUT: Passes a value from the procedure back to the caller. The parameter’s initial value in the procedure is NULL; the procedure usually changes that value, and the final value is visible to the caller when the procedure returns.
INOUT: The caller initializes an INOUT parameter, but the procedure can modify the value, and the final value is visible to the caller when the procedure returns.