getting error when clear cache in drupal Following Error occure when i clear cache from admin in drupal:


  PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062
  Duplicate entry 'seven-views-retailers_view-block' for key 'tmd':
  INSERT INTO {block} (module, delta, theme, status, weight, region,
  pages, cache) VALUES (:db_insert_placeholder_0,
  :db_insert_placeholder_1, :db_insert_placeholder_2,
  :db_insert_placeholder_3, :db_insert_placeholder_4,
  :db_insert_placeholder_5, :db_insert_placeholder_6,
  :db_insert_placeholder_7); Array ( [:db_insert_placeholder_0] => views
  [:db_insert_placeholder_1] => retailers_view-block
  [:db_insert_placeholder_2] => seven [:db_insert_placeholder_3] => 0
  [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => -1
  [:db_insert_placeholder_6] => [:db_insert_placeholder_7] => -1 ) in
  drupal_write_record() (line 7106 of
  /home/nxsol/webdata/latestspecialsonline.co.za/includes/common.inc).
Consider using db_merge if you want to write when the record doesn't exist and update if the record exists. In fact at the business logic level you should check if a record exists or not before making an insert or update. That way you will have more control. 

And regarding the problem you are facing only when you clear cache, it can be that somewhere in your code when you have an entry in cache you are not making an insert. But when there is no entry in the cache, you are making an insert. So every time you clear the cache an insert is being attempted with the same key which might be causing the problem.