DROP PROCEDURE scope_test; / CREATE PROCEDURE scope_test( ) BEGIN DECLARE outer_variable VARCHAR(30); SET outer_variable = 'Sam'; BEGIN -- start inner block DECLARE inner_variable VARCHAR(30); SET inner_variable = 'This is my inner variable'; SET outer_variable = 'This is the outer variable'; -- SELECT inner_variable, outer_variable; -- both are OK END; -- SELECT outer_variable; -- this is OK SELECT inner_variable; -- this is ERROR END; / CALL scope_test();