title: Temporary Table in Stored Procedure Not Found in MySQL
body: <p>I've inherited some code that uses stored procedures and one of them doesn't appear to be working correctly. </p>
  
  <p>The stored procedure uses a temporary table to insert data later in the procedure.  However when I execute the stored procedure, no data is inserted.  When I debug it, I get the error: </p>
  
  <p><code>Table 'db.testtable' doesn't exist</code></p>
  
  <p>I've stripped down the stored procedure to the following code, and it doesn't work.  I always get the error on the SELECT statement.  Everything looks OK from what I can tell based on the examples I've seen.</p>
  
  <pre><code>DROP PROCEDURE IF EXISTS db.insert_record;
  CREATE PROCEDURE db.`insert_record`(id int, status int)
  BEGIN
      DECLARE code varchar(45);
  
      DROP TEMPORARY TABLE IF EXISTS testTable;
  
      CREATE TEMPORARY TABLE testTable AS (SELECT 'TEST' AS fakeColumn);
  
      SELECT fakeColumn INTO code FROM testTable;
  END;
  </code></pre>
  
  <p>I've also verified that the user I am connected as has the permission to create temporary tables; in fact it has every permission available</p>
  
  <p><strong>Additional Details</strong></p>
  
  <p>Running MySQL 5.6 on Windows.</p>
  
  <p>If I take the drop / create / select statements by themselves and run as a script, it behaves as expected.</p>
  
  <p>Using Toad for MySQL to debug the stored procedure.</p>