title: How to identify current database while inside a stored procedure?
body: <p>I am trying to write a simple stored procedure which will clear the contents of <em>some</em> tables in the current database - I'm doing this by matching a prefix against the list of tables in the information_schema:</p>
  
  <pre><code>delimiter $$
  create procedure local_flush_cache(db varchar(255))
  begin
  
  select @str_sql:=concat('delete from ',group_concat(table_name))
  from information_schema.tables
  where table_schema=db and table_name like 'cache_%';
  
  prepare stmt from @str_sql;
  
  execute stmt;
  
  drop prepare stmt;
  
  end$$
  delimiter ;
  </code></pre>
  
  <p>I would like to be able to remove the db parameter and have the function work on the currently active database.</p>
  
  <p>I guess I will also need the ability to recognise that a database has not yet been selected and output an error (to prevent accidentally flushing all cache tables in all databases).</p>