mysql>
mysql> delimiter $$
mysql>
mysql> CREATE PROCEDURE myProc()
-> BEGIN
-> DECLARE my_variable VARCHAR(20);
-> SET my_variable='This value was set in the outer block';
-> BEGIN
-> DECLARE my_variable VARCHAR(20);
-> SET my_variable='This value was set in the inner block';
-> END;
-> SELECT my_variable, 'Can''t see changes made in the inner block';
-> END$$
Query OK, 0 rows affected (0.02 sec)
mysql> delimiter ;
mysql>
mysql> call myProc();
+----------------------+-------------------------------------------+
| my_variable | Can't see changes made in the inner block |
+----------------------+-------------------------------------------+
| This value was set i | Can't see changes made in the inner block |
+----------------------+-------------------------------------------+
1 row in set (0.00 sec)
Query OK, 0 rows affected, 2 warnings (0.00 sec)
mysql> drop procedure myProc;
Query OK, 0 rows affected (0.02 sec)
mysql>
mysql>