CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Import (Moderator: Yashodha Chaku) »
  • Constraint Violation when importing event participants
Pages: [1]

Author Topic: Constraint Violation when importing event participants  (Read 1251 times)

John Thompson

  • I’m new here
  • *
  • Posts: 11
  • Karma: 0
  • CiviCRM version: 4.4.5
  • CMS version: WP 3.9.1
  • MySQL version: 5.1
  • PHP version: 5.3.8
Constraint Violation when importing event participants
July 14, 2014, 10:32:55 pm
When importing some event participants, I get a constraint violation error (backtrace)
Code: [Select]
#0 /home/reachov5/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Error.php(149): CRM_Core_Error::backtrace()
#1 [internal function](): CRM_Core_Error::handle(Object(DB_Error))
#2 /home/reachov5/public_html/wp-content/plugins/civicrm/civicrm/packages/PEAR.php(931): call_user_func((Array:2), Object(DB_Error))
#3 /home/reachov5/public_html/wp-content/plugins/civicrm/civicrm/packages/DB.php(969): PEAR_Error->PEAR_Error("DB Error: constraint violation", -3, 16, (Array:2), "INSERT INTO civicrm_participant (contact_id , event_id , status_id , role_id ...")
#4 /home/reachov5/public_html/wp-content/plugins/civicrm/civicrm/packages/PEAR.php(564): DB_Error->DB_Error(-3, 16, (Array:2), "INSERT INTO civicrm_participant (contact_id , event_id , status_id , role_id ...")
#5 /home/reachov5/public_html/wp-content/plugins/civicrm/civicrm/packages/DB/common.php(1905): PEAR->raiseError(NULL, -3, NULL, NULL, "INSERT INTO civicrm_participant (contact_id , event_id , status_id , role_id ...", "DB_Error", TRUE)
#6 /home/reachov5/public_html/wp-content/plugins/civicrm/civicrm/packages/DB/mysql.php(898): DB_common->raiseError(-3, NULL, NULL, NULL, "1452 ** Cannot add or update a child row: a foreign key constraint fails (`re...")
#7 /home/reachov5/public_html/wp-content/plugins/civicrm/civicrm/packages/DB/mysql.php(327): DB_mysql->mysqlRaiseError()
#8 /home/reachov5/public_html/wp-content/plugins/civicrm/civicrm/packages/DB/common.php(1216): DB_mysql->simpleQuery("INSERT INTO civicrm_participant (contact_id , event_id , status_id , role_id ...")
#9 /home/reachov5/public_html/wp-content/plugins/civicrm/civicrm/packages/DB/DataObject.php(2421): DB_common->query("INSERT INTO civicrm_participant (contact_id , event_id , status_id , role_id ...")
#10 /home/reachov5/public_html/wp-content/plugins/civicrm/civicrm/packages/DB/DataObject.php(1055): DB_DataObject->_query("INSERT INTO civicrm_participant (contact_id , event_id , status_id , role_id ...")
#11 /home/reachov5/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/DAO.php(278): DB_DataObject->insert()
#12 /home/reachov5/public_html/wp-content/plugins/civicrm/civicrm/CRM/Event/BAO/Participant.php(137): CRM_Core_DAO->save()
#13 /home/reachov5/public_html/wp-content/plugins/civicrm/civicrm/CRM/Event/BAO/Participant.php(200): CRM_Event_BAO_Participant::add((Array:8))
#14 /home/reachov5/public_html/wp-content/plugins/civicrm/civicrm/api/v3/Participant.php(70): CRM_Event_BAO_Participant::create((Array:8))
#15 /home/reachov5/public_html/wp-content/plugins/civicrm/civicrm/CRM/Utils/DeprecatedUtils.php(1219): civicrm_api3_participant_create((Array:8))
#16 /home/reachov5/public_html/wp-content/plugins/civicrm/civicrm/CRM/Event/Import/Parser/Participant.php(456): _civicrm_api3_deprecated_create_participant_formatted((Array:8), "1")
#17 /home/reachov5/public_html/wp-content/plugins/civicrm/civicrm/CRM/Event/Import/Parser.php(161): CRM_Event_Import_Parser_Participant->import("1", (Array:14))
#18 /home/reachov5/public_html/wp-content/plugins/civicrm/civicrm/CRM/Event/Import/Form/Preview.php(147): CRM_Event_Import_Parser->run((Array:2), ",", (Array:14), "1", 8, 1, "1")
#19 /home/reachov5/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Form.php(261): CRM_Event_Import_Form_Preview->postProcess()
#20 /home/reachov5/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/StateMachine.php(160): CRM_Core_Form->mainProcess()
#21 /home/reachov5/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/QuickForm/Action/Next.php(60): CRM_Core_StateMachine->perform(Object(CRM_Event_Import_Form_Preview), "next", "Next")
#22 /home/reachov5/public_html/wp-content/plugins/civicrm/civicrm/packages/HTML/QuickForm/Controller.php(203): CRM_Core_QuickForm_Action_Next->perform(Object(CRM_Event_Import_Form_Preview), "next")
#23 /home/reachov5/public_html/wp-content/plugins/civicrm/civicrm/packages/HTML/QuickForm/Page.php(103): HTML_QuickForm_Controller->handle(Object(CRM_Event_Import_Form_Preview), "next")
#24 /home/reachov5/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Controller.php(339): HTML_QuickForm_Page->handle("next")
#25 /home/reachov5/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(323): CRM_Core_Controller->run((Array:3), NULL)
#26 /home/reachov5/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(72): CRM_Core_Invoke::runItem((Array:14))
#27 /home/reachov5/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(52): CRM_Core_Invoke::_invoke((Array:3))
#28 /home/reachov5/public_html/wp-content/plugins/civicrm/civicrm.php(470): CRM_Core_Invoke::invoke((Array:3))
#29 [internal function](): CiviCRM_For_WordPress->invoke("")
#30 /home/reachov5/public_html/wp-includes/plugin.php(470): call_user_func_array((Array:2), (Array:1))
#31 /home/reachov5/public_html/wp-admin/admin.php(211): do_action("toplevel_page_CiviCRM")

When I try inserting a row in the civicrm_participant table using this query:
Code: [Select]
INSERT INTO `reachov5_CiviCRM`.`civicrm_participant` (`id`, `contact_id`, `event_id`, `status_id`, `role_id`, `register_date`, `source`, `fee_level`, `is_test`, `is_pay_later`, `fee_amount`, `registered_by_id`, `discount_id`, `fee_currency`, `campaign_id`, `discount_amount`, `cart_id`, `must_wait`) VALUES (NULL, '714', '9', '2', '1', NULL, NULL, NULL, '0', '0', NULL, '637', NULL, NULL, NULL, NULL, NULL, NULL)

I get a MySQL error:
Code: [Select]
#1452 - Cannot add or update a child row: a foreign key constraint fails (`reachov5_CiviCRM`.`civicrm_participant`, CONSTRAINT `FK_civicrm_participant_registered_by_id` FOREIGN KEY (`registered_by_id`) REFERENCES `civicrm_participant` (`id`) ON DELETE SET NULL)

I've checked that the registered_by_id value is a valid contact (organization) and the contact_id is valid (individual). Also the event_id, status_id and role_id are valid.

This doesn't happen when adding all participant but just some. I thought that the problem occurs when the registered_by contact has a contact_sub_type other than null but now I don't know for sure that is the case.

Any help would be appreciated. I has me stopped in my track with another 2000 participants to import.

Thanks

John Thompson

  • I’m new here
  • *
  • Posts: 11
  • Karma: 0
  • CiviCRM version: 4.4.5
  • CMS version: WP 3.9.1
  • MySQL version: 5.1
  • PHP version: 5.3.8
Re: Constraint Violation when importing event participants
July 15, 2014, 08:41:35 am
I have some new information that might help:

At least in this particular case the participant I'm importing, 714, has a relationship with contact 637 (is an employee of the organization 637). Contact 637 is the registered_by_id. What I'm trying to indicate here is that the employee was registered for the event by his employer. Is that a problem or is there a different way of doing it?

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Import (Moderator: Yashodha Chaku) »
  • Constraint Violation when importing event participants

This forum was archived on 2017-11-26.