Parameters make the stored procedure more useful and flexible. In MySQL, we have the following three kinds of modes −
It is the default mode. When we define an IN parameter in a stored procedure, the calling program has to pass an argument to the stored procedure. The value of an IN parameter is protected which means that even the value of the IN parameter is changed inside the stored procedure; its original value is retained after the stored procedure ends.
The value of an OUT parameter can be changed inside the stored procedure and its new value is passed back to the calling program. It is to be noticed that the stored procedure cannot access the initial value of the OUT parameter when it starts.
An INOUT parameter is the combination of IN and OUT parameters which means that the calling program may pass the argument, and the stored procedure can modify the INOUT parameter and pass the new value back to the calling program.
Following is the syntax of defining a parameter in the stored procedure −
MODE parameter_name parameter_type(parameter_size)
Here, MODE can be IN, OUT or INOUT which depends upon the purpose of the parameter in the stored purpose.