title: MySQL : transaction within a stored procedure
body: <p>The basic structure of my stored procedure is,</p>
  
  <pre><code>BEGIN
  
      .. Declare statements ..
  
      START TRANSACTION;
  
          .. Query 1 ..
          .. Query 2 ..
          .. Query 3 ..
  
      COMMIT;
  
  END
  </code></pre>
  
  <blockquote>
    <p><strong>MySQL version:</strong> 5.1.61-0ubuntu0.11.10.1-log</p>
  </blockquote>
  
  <p>Currently, if 'query 2' fails, result of 'query 1' is committed.</p>
  
  <ul>
  <li>How can I rollback the transaction if any of the query fails?</li>
  </ul>