title: Error while doing insert/update in MySql
body: <p>I want to capture the error occurring during inserting or updating data in mysql Stored procedures.</p>
  
  <p>When a data is updated in DB, no of rows modified can be checked to know whether update or insert happened successfully or not, but even if rows affected is 0 (same data updated again), it may not be an error condition.</p>
  
  <p>i want to capture only insert/update is failed.
  Please share some light on the same</p>
  
  <p>My Sp is something like below </p>
  
  <pre><code>DELIMITER $$
  
      CREATE PROCEDURE `sp_test`(
              IN param1 VARCHAR(50), 
              IN param2 VARCHAR(50)
          )
          BEGIN
              IF updateCount &gt; 0 THEN
                  UPDATE tbname SET val = param1 where con = param2;
              ELSE
                  INSERT INTO tbname SET val = param1,con = param2;
              END IF;
  
          END$$
  
  DELIMITER ;
  </code></pre>
  
  <p>I want to track whether the statements has executed successfully or not.</p>