title: How to tell if mysql stored procedure executed successfully
body: <p>I have a stored procedure that updates two tables and then inserts a row in to a third table. (And to my understanding, rolls back the updates or insert if all three cannot be done) Anyway, whenever I run this procedure, regardless if it ends up successfully running the two updates and insert or not, it will always be "successful" and return false. I need it to return a value (probably true) if it successfully does all two updates and one insert and false if it does not so I can do the correct error checking on the server side. </p>
  
  <p>Here is the procedure: </p>
  
  <pre><code>CREATE DEFINER=`db1`@`%` PROCEDURE `completed_procedure`(IN insubmissionid INT)
  BEGIN
  
  DECLARE ingregid INT;
  DECLARE EXIT HANDLER FOR SQLEXCEPTION ROLLBACK;
  DECLARE EXIT HANDLER FOR SQLWARNING ROLLBACK;
  
  START TRANSACTION;
  
  SET @ingregid = (SELECT idgreg FROM submission WHERE idsubmission = insubmissionid);
  
  UPDATE submission SET status='a' WHERE idsubmission = insubmissionid;
  
  UPDATE greg SET iscomplete=1 WHERE idgreg = @ingregid;
  
  INSERT INTO completion (idperson, idgreg, datecompleted, idsubmission, mediaid, description,
      privatestatus, contenttype, totalamount)  
  SELECT s.idperson, s.idgreg, s.datesubmitted, s.idsubmission,
      COALESCE(s.youtubeid, s.contentid) AS mediaidid, g.description, g.privatestatus,
      g.contenttype, COALESCE(SUM(amount),0) AS totalamount 
  FROM submission s 
  INNER JOIN greg g on s.idgreg = g.idgreg
  INNER JOIN contribution c on s.idgreg = c.idgreg 
  WHERE s.idsubmission = insubmissionid AND c.ispaid = 1;
  
  COMMIT;
  END
  </code></pre>
  
  <p>What is the best way to go about this?</p>