title: Using session variables in a stored procedure
body: <p>I just started learning MySQL and creating stored procedures. This procedure works fine when I use local variables. When I try to use a session variable in my procedure I receive a syntax error. <strong>Can I not use session parameters in procedures and if not, where can I use them?</strong> </p>
  
  <pre><code>DELIMITER $$
  CREATE PROCEDURE myfirst()
  BEGIN
  DECLARE @counter INT DEFAULT 1;
  DECLARE @result VARCHAR(30); 
  WHILE (counter &lt; (SELECT count(*) FROM animals))
  DO
  SET result= (SELECT name FROM animals WHERE id = counter);
  SELECT result;
  SET counter = counter + 1;
  END while;
  
  END$$
  DELIMITER ;
  </code></pre>