Answers.Body: <p>I have resolved the issue.  It appears there was a null entry in  civicrm_custom_group associated with the contact table and deleting this fixed the problem</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-12-19T09:12:26.697Z
Answers.LastActivityDate: 2016-12-19T09:12:26.697Z
Answers.UserDisplayName: Alg
Body: <p>I have a vanilla CiviCRM setup which has been running for quite some time.
  I'm currently running  4.7.14.   When attempting to merge records I get a transaction integrity error (see below for backtrace), which points to some sort of SQL error. Merging has worked in the past.  Any ideas what the problem could be?</p>
  
  <p>Thanks!</p>
  
  <pre><code>#0 /sites/all/modules/civicrm/CRM/Core/Error.php(187):
  CRM_Core_Error::backtrace()
  #1 [internal function](): CRM_Core_Error::handle(Object(DB_Error))
  #2 /sites/all/modules/civicrm/packages/PEAR.php(921):
  call_user_func((Array:2), Object(DB_Error))
  #3 /sites/all/modules/civicrm/packages/DB.php(985):
  PEAR_Error-&gt;__construct("DB Error: syntax error", -2, 16, (Array:2),
  "UPDATE IGNORE  SET entity_id = 311 WHERE entity_id = 312
  [nativecode=1064 ** ...")
  #4 /sites/all/modules/civicrm/packages/PEAR.php(575):
  DB_Error-&gt;__construct(-2, 16, (Array:2), "UPDATE IGNORE  SET entity_id
  = 311 WHERE entity_id = 312 [nativecode=1064 ** ...")
  #5 [internal function](): PEAR-&gt;_raiseError(Object(DB_mysqli), NULL,
  -2, NULL, NULL, "UPDATE IGNORE  SET entity_id = 311 WHERE entity_id =
  312 [nativecode=1064 ** ...", "DB_Error", TRUE)
  #6 /sites/all/modules/civicrm/packages/PEAR.php(224):
  call_user_func_array((Array:2), (Array:8))
  #7 /sites/all/modules/civicrm/packages/DB/common.php(1905):
  PEAR-&gt;__call("raiseError", (Array:7))
  #8 /sites/all/modules/civicrm/packages/DB/common.php(1905):
  PEAR-&gt;raiseError(NULL, -2, NULL, NULL, "UPDATE IGNORE  SET entity_id =
  311 WHERE entity_id = 312 [nativecode=1064 ** ...", "DB_Error", TRUE)
  #9 /sites/all/modules/civicrm/packages/DB/mysqli.php(933):
  DB_common-&gt;raiseError(-2, NULL, NULL, NULL, "1064 ** You have an error
  in your SQL syntax; check the manual that correspon...")
  #10 /sites/all/modules/civicrm/packages/DB/mysqli.php(403):
  DB_mysqli-&gt;mysqliRaiseError()
  #11 /sites/all/modules/civicrm/packages/DB/common.php(1216):
  DB_mysqli-&gt;simpleQuery("UPDATE IGNORE  SET entity_id = 311 WHERE
  entity_id = 312")
  #12 /sites/all/modules/civicrm/packages/DB/DataObject.php(2438):
  DB_common-&gt;query("UPDATE IGNORE  SET entity_id = 311 WHERE entity_id =
  312")
  #13 /sites/all/modules/civicrm/packages/DB/DataObject.php(1627):
  DB_DataObject-&gt;_query("UPDATE IGNORE  SET entity_id = 311 WHERE
  entity_id = 312")
  #14 /sites/all/modules/civicrm/CRM/Core/DAO.php(354):
  DB_DataObject-&gt;query("UPDATE IGNORE  SET entity_id = 311 WHERE
  entity_id = 312")
  #15 /sites/all/modules/civicrm/CRM/Core/DAO.php(1297):
  CRM_Core_DAO-&gt;query("UPDATE IGNORE  SET entity_id = 311 WHERE
  entity_id = 312", TRUE)
  #16 /sites/all/modules/civicrm/CRM/Dedupe/Merger.php(531):
  CRM_Core_DAO::executeQuery("UPDATE IGNORE  SET entity_id = 311 WHERE
  entity_id = 312", (Array:0), TRUE, NULL, TRUE)
  #17 /sites/all/modules/civicrm/CRM/Dedupe/Merger.php(1486):
  CRM_Dedupe_Merger::moveContactBelongings("311", "312")
  #18 /sites/all/modules/civicrm/CRM/Contact/Form/Merge.php(328):
  CRM_Dedupe_Merger::moveAllBelongings("311", "312", (Array:20))
  #19 /sites/all/modules/civicrm/CRM/Core/Form.php(435):
  CRM_Contact_Form_Merge-&gt;postProcess()
  #20 /sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Done.php(75):
  CRM_Core_Form-&gt;mainProcess()
  #21 /sites/all/modules/civicrm/packages/HTML/QuickForm/Controller.php(203):
  CRM_Core_QuickForm_Action_Done-&gt;perform(Object(CRM_Contact_Form_Merge),
  "done")
  #22 /sites/all/modules/civicrm/packages/HTML/QuickForm/Page.php(103):
  HTML_QuickForm_Controller-&gt;handle(Object(CRM_Contact_Form_Merge),
  "done")
  #23 /sites/all/modules/civicrm/CRM/Core/Controller.php(351):
  HTML_QuickForm_Page-&gt;handle("done")
  #24 /sites/all/modules/civicrm/CRM/Utils/Wrapper.php(113):
  CRM_Core_Controller-&gt;run()
  #25 /sites/all/modules/civicrm/CRM/Core/Invoke.php(284):
  CRM_Utils_Wrapper-&gt;run("CRM_Contact_Form_Merge", "Merge Contact",
  NULL)
  #26 /sites/all/modules/civicrm/CRM/Core/Invoke.php(84):
  CRM_Core_Invoke::runItem((Array:13))
  #27 /sites/all/modules/civicrm/CRM/Core/Invoke.php(52):
  CRM_Core_Invoke::_invoke((Array:3))
  #28 /sites/all/modules/civicrm/drupal/civicrm.module(448):
  CRM_Core_Invoke::invoke((Array:3))
  #29 [internal function](): civicrm_invoke("contact", "merge")
  #30 /includes/menu.inc(527):
  call_user_func_array("civicrm_invoke", (Array:2))
  #31 /index.php(21): menu_execute_active_handler()
  #32 {main}
  </code></pre>
  
Tags: <drupal><duplicate-contacts>
Title: Transaction integrity error when merging
ThreadText: # Transaction integrity error when merging
  
  (Asked by: username_0 on 2016-12-19)
  
  I have a vanilla CiviCRM setup which has been running for quite some time.
  I'm currently running  4.7.14.   When attempting to merge records I get a transaction integrity error (see below for backtrace), which points to some sort of SQL error. Merging has worked in the past.  Any ideas what the problem could be?
  Thanks!
  #0 /sites/all/modules/civicrm/CRM/Core/Error.php(187):
  CRM_Core_Error::backtrace()
  #1 [internal function](): CRM_Core_Error::handle(Object(DB_Error))
  #2 /sites/all/modules/civicrm/packages/PEAR.php(921):
  call_user_func((Array:2), Object(DB_Error))
  #3 /sites/all/modules/civicrm/packages/DB.php(985):
  PEAR_Error->__construct("DB Error: syntax error", -2, 16, (Array:2),
  "UPDATE IGNORE  SET entity_id = 311 WHERE entity_id = 312
  [nativecode=1064 ** ...")
  #4 /sites/all/modules/civicrm/packages/PEAR.php(575):
  DB_Error->__construct(-2, 16, (Array:2), "UPDATE IGNORE  SET entity_id
  = 311 WHERE entity_id = 312 [nativecode=1064 ** ...")
  #5 [internal function](): PEAR->_raiseError(Object(DB_mysqli), NULL,
  -2, NULL, NULL, "UPDATE IGNORE  SET entity_id = 311 WHERE entity_id =
  312 [nativecode=1064 ** ...", "DB_Error", TRUE)
  #6 /sites/all/modules/civicrm/packages/PEAR.php(224):
  call_user_func_array((Array:2), (Array:8))
  #7 /sites/all/modules/civicrm/packages/DB/common.php(1905):
  PEAR->__call("raiseError", (Array:7))
  #8 /sites/all/modules/civicrm/packages/DB/common.php(1905):
  PEAR->raiseError(NULL, -2, NULL, NULL, "UPDATE IGNORE  SET entity_id =
  311 WHERE entity_id = 312 [nativecode=1064 ** ...", "DB_Error", TRUE)
  #9 /sites/all/modules/civicrm/packages/DB/mysqli.php(933):
  DB_common->raiseError(-2, NULL, NULL, NULL, "1064 ** You have an error
  in your SQL syntax; check the manual that correspon...")
  #10 /sites/all/modules/civicrm/packages/DB/mysqli.php(403):
  DB_mysqli->mysqliRaiseError()
  #11 /sites/all/modules/civicrm/packages/DB/common.php(1216):
  DB_mysqli->simpleQuery("UPDATE IGNORE  SET entity_id = 311 WHERE
  entity_id = 312")
  #12 /sites/all/modules/civicrm/packages/DB/DataObject.php(2438):
  DB_common->query("UPDATE IGNORE  SET entity_id = 311 WHERE entity_id =
  312")
  #13 /sites/all/modules/civicrm/packages/DB/DataObject.php(1627):
  DB_DataObject->_query("UPDATE IGNORE  SET entity_id = 311 WHERE
  entity_id = 312")
  #14 /sites/all/modules/civicrm/CRM/Core/DAO.php(354):
  DB_DataObject->query("UPDATE IGNORE  SET entity_id = 311 WHERE
  entity_id = 312")
  #15 /sites/all/modules/civicrm/CRM/Core/DAO.php(1297):
  CRM_Core_DAO->query("UPDATE IGNORE  SET entity_id = 311 WHERE
  entity_id = 312", TRUE)
  #16 /sites/all/modules/civicrm/CRM/Dedupe/Merger.php(531):
  CRM_Core_DAO::executeQuery("UPDATE IGNORE  SET entity_id = 311 WHERE
  entity_id = 312", (Array:0), TRUE, NULL, TRUE)
  #17 /sites/all/modules/civicrm/CRM/Dedupe/Merger.php(1486):
  CRM_Dedupe_Merger::moveContactBelongings("311", "312")
  #18 /sites/all/modules/civicrm/CRM/Contact/Form/Merge.php(328):
  CRM_Dedupe_Merger::moveAllBelongings("311", "312", (Array:20))
  #19 /sites/all/modules/civicrm/CRM/Core/Form.php(435):
  CRM_Contact_Form_Merge->postProcess()
  #20 /sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Done.php(75):
  CRM_Core_Form->mainProcess()
  #21 /sites/all/modules/civicrm/packages/HTML/QuickForm/Controller.php(203):
  CRM_Core_QuickForm_Action_Done->perform(Object(CRM_Contact_Form_Merge),
  "done")
  #22 /sites/all/modules/civicrm/packages/HTML/QuickForm/Page.php(103):
  HTML_QuickForm_Controller->handle(Object(CRM_Contact_Form_Merge),
  "done")
  #23 /sites/all/modules/civicrm/CRM/Core/Controller.php(351):
  HTML_QuickForm_Page->handle("done")
  #24 /sites/all/modules/civicrm/CRM/Utils/Wrapper.php(113):
  CRM_Core_Controller->run()
  #25 /sites/all/modules/civicrm/CRM/Core/Invoke.php(284):
  CRM_Utils_Wrapper->run("CRM_Contact_Form_Merge", "Merge Contact",
  NULL)
  #26 /sites/all/modules/civicrm/CRM/Core/Invoke.php(84):
  CRM_Core_Invoke::runItem((Array:13))
  #27 /sites/all/modules/civicrm/CRM/Core/Invoke.php(52):
  CRM_Core_Invoke::_invoke((Array:3))
  #28 /sites/all/modules/civicrm/drupal/civicrm.module(448):
  CRM_Core_Invoke::invoke((Array:3))
  #29 [internal function](): civicrm_invoke("contact", "merge")
  #30 /includes/menu.inc(527):
  call_user_func_array("civicrm_invoke", (Array:2))
  #31 /index.php(21): menu_execute_active_handler()
  #32 {main}
  
  **Tags:** drupal, duplicate-contacts
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2016-12-19. Score: 2
  
  I have resolved the issue. It appears there was a null entry in civicrm\_custom\_group associated with the contact table and deleting this fixed the problem
  
  
  ---
  
  