title: MySQL - How to throw exception in stored procedure?
body: <p>How to generate an exception in the stored procedure in MySQL? For example:</p>
  
  <pre><code>CREATE PROCEDURE SALES()
  BEGIN
  
  STATEMENT...
  STATEMENT...
  STATEMENT...
  
  IF (PRICE &gt;= 500) THEN
  /** THROWS AN EXCEPTION....  
      WHAT DO TO STOP THE PROCEDURE. **/
  END IF;
  
  STATEMENT...
  STATEMENT...
  STATEMENT...
  
  END;
  </code></pre>
  
  <p>In MySQL I think there is no way to throw an exception in a stored procedure, but I can force an error by selecting from a non-existing table. For example:</p>
  
  <pre><code>IF (PRICE &gt; 500) THEN
      /*throw the error here*/
      SELECT * FROM price_greater_than_500_in_throw_exception;
  END IF;
  </code></pre>
  
  <p>Is there a more elegant way?</p>
  
  <p>Thanks.</p>