title: Variable scope within a stored procedure?
body: <p>I have noticed in mysql that why preparing a dynamic query it requires what I think is a global variable.  Is there a way to limit the scope of the variable to only betwenn the begin and end statements?  Below is my test script when returns a value of 10 for the limitCnt variable.</p>
  
  <pre><code>delimiter //
  drop procedure if exists testProc//
  create procedure testProc ()
  begin
  --  DECLARE limitCnt INT default 10;
    SET @limitCnt = 10;
  
    PREPARE stmt FROM 'SELECT * FROM `participants` LIMIT ?';
    EXECUTE stmt USING @limitCnt; -- the using part of the execute does not like the local variable
  
    DEALLOCATE PREPARE stmt;
  end//
  call testProc()//
  select @limitCnt//
  
  drop procedure testProc//
  delimiter ;
  </code></pre>