Variables : Variable Declaration « Procedure Function « MySQL Tutorial






Stored procedures can access and set local, session, and global variables.

Local variables are either passed in as parameters or created using the DECLARE statement.

Using the DECLARE statement with a DEFAULT will set the value of a local variable:

DECLARE myInt INT DEFAULT 0;

You can assign values to local, session, and global variables using the SET statement:

SET myInt = 5;

MySQL's SET statement permits setting multiple variables in one statement:

SET myInt1 = 5, myInt2 = 50;
11.10.Variable Declaration
11.10.1.Variables
11.10.2.Declare INTEGER variable in procedure