title: How to CALL a PROCEDURE in MySQL?
body: <p>I've started to examine Procedures in MySQL, but all my efforts don't work. Here is my Procedure Creation:</p>
  
  <pre><code>DELIMITER //
  CREATE PROCEDURE test(IN a INT)
  BEGIN
      SELECT * 
      FROM `table`
      WHERE `id` = a;
  END
  </code></pre>
  
  <p>MySQL returns O.K., no errors.</p>
  
  <pre><code> DELIMITER ;
  </code></pre>
  
  <p>MySQL returns O.K., no errors.</p>
  
  <p>But CALL-Statement does not work:</p>
  
  <pre><code>CALL test(8);
  </code></pre>
  
  <p>Returns an error:
       #1312 - PROCEDURE dbxyz.test can't return a result set in the given context </p>
  
  <p>Now, I don't know what I've made wrong: a mistake in Procedure-Cration or an error in CALL-Statement. </p>
  
  <p>--> ##########################</p>
  
  <p>As of 6th Feb. 2014:
  Today, I've tried to find out, why my Stored Procedure does not work in Query Window of phpMyAdmin. A 'SELECT *' does not work within a Stored Procedure, but a SELECT column by column does work. Here is what I have found out: Use IN and OUT as well as INTO. Example: </p>
  
  <pre><code> DELIMITER //
   CREATE PROCEDURE test(IN a INT, OUT b VARCHAR(12), OUT c INT)
   BEGIN
     SELECT b, c
     FROM `table`
     WHERE `id` = a
     INTO b, c;
   END
  </code></pre>
  
  <p>Now, this stored Procedure is able to run in phpMyAdmin:</p>
  
  <pre><code> call test(5, @result1, @result2);
   SELECT @result1, @result2
  </code></pre>
  
  <p>If you just need ONE result instad of two or more, you could also use SET - Statement. Here we are:</p>
  
  <pre><code>   DELIMITER //
     CREATE PROCEDURE test(IN a INT, OUT b INT)
     BEGIN
          SET b = ( SELECT b
          FROM table
          WHERE id = a );
     END
  </code></pre>