title: MySQL Stored Procedure : delete entry if table exists
body: <p>I have created a stored procedure, which should delte data from some tables.</p>
  
  <p>On my productive db I have tables which I have not in my local db (different schema names).</p>
  
  <p>Is there an elegant way to query the data tables existence to avoid exceptions? Maybe declare an error handler which catches the specific error and should continue.</p>
  
  <pre><code>CREATE PROCEDURE `deletion`(IN s_id varchar(255))
  BEGIN   
      DECLARE has_error BOOL DEFAULT FALSE;
      /* for all other exception there should be a rollback, if table does not exist
          then continue*/
      DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET has_error = TRUE; 
  
  START TRANSACTION;
  
  DELETE FROM a WHERE id = s_id;
  DELETE FROM b WHERE id = s_id;
  DELETE FROM c WHERE id = s_id;
  DELETE FROM d WHERE id = s_id;
  
  IF has_error THEN
    ROLLBACK;
   ELSE
    COMMIT;
  END IF;
  
  END
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I tried this, but this is not working. even if the table exists the entry is not deleted:</p>
  
  <pre><code> IF EXISTS (SELECT 1 from information_schema.tables 
      WHERE table_schema = 'a' ) then
          DELETE FROM at WHERE id = s_id; 
      END IF;
  </code></pre>
  
  <p>thanks in advance!</p>