0

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).

  • there is something wrong with query written programmatically – harshal Sep 5 '13 at 6:06
  • A shot in the dark 1. take export of view seven-views-retailers_view-block as backup. 2. Disable the view seven-views-retailers_view-block. 3. Clear your cache 4. If you see no error this time,enable the view again and try clearing the caches. – arpitr Sep 5 '13 at 7:10
2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.