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 CiviEvent (Moderator: Yashodha Chaku) »
  • Help with a database error
Pages: [1]

Author Topic: Help with a database error  (Read 1000 times)

baparks

  • I’m new here
  • *
  • Posts: 16
  • Karma: 0
Help with a database error
February 15, 2010, 08:27:48 am
While filling out an oline registration one of the users got the following error:

Sorry. A non-recoverable error has occurred.
DB Error: constraint violation
Database Error Code: Cannot add or update a child row: a foreign key constraint fails (`db301708404/civicrm_value_rooming_2`, CONSTRAINT
`FK_civicrm_value_rooming_2_entity_id` FOREIGN KEY (`entity_id`) REFERENCES `civicrm_event` (`id`) ON DELETE CASCADE), 1452
Return to home page.
Error Details:
Array
(
[callback] => Array
(
  • => CRM_Core_Error
  • [1] => handle
    )
Code: [Select]
=> -3
[message] => DB Error: constraint violation
[mode] => 16
[debug_info] => INSERT INTO civicrm_value_rooming_2 ( room_requirements_2,i_plan_to_share_the_room_with_3,entity_id ) VALUES ( ' I will reserve a room. ','',[type] => DB_Error
[user_info] => INSERT INTO civicrm_value_rooming_2 ( room_requirements_2,i_plan_to_share_the_room_with_3,entity_id ) VALUES ( ' I will reserve a room. ','',[to_string] => [db_error: message="DB Error: constraint violation" code=-3 mode=callback callback=CRM_Core_Error::handle prefix="" info="INSERT INTO


This is a live site so help is most needed and appreciated!

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Help with a database error
February 15, 2010, 02:51:09 pm
Not much info provided here :-(
Is this workflow tested / works almost all the time - but this user got an error for some reason?

Based on just the query snippet / error - it seems like things might not be configured properly in your custom fields / profile setup. I may be missing a valid use case BUT I would not expect a custom field referencing EVENT to be used in an online registration form. If you're collecting info from folks registering for an event - custom fields 'used for' Contact (individuals)  AND / OR Participant are expected. More info might help:

CiviCRM version
any checking of CiviCRM.log.* you've done
frequency / context of error
custom field config
profile fields on the online reg form

... or if this is really time sensitive, you might engage paid help from someone on the Professsional Services page (link above).
Protect your investment in CiviCRM by  becoming a Member!

seashell

  • I’m new here
  • *
  • Posts: 24
  • Karma: 0
Re: Help with a database error
March 29, 2010, 09:31:31 am
I am receiving a similar error;however, both sets of custom data within the registration are related to a customProfile (Contact) and bottom of the event form the Participant set of custom fields.  Wondering perhaps if the foreign key being reference is the participant ID record. If the database doesn't have time to return this key then when it attempts to write to the custom participant record the key may not exist.

Sorry. A non-recoverable error has occurred.

DB Error: constraint violation

Database Error Code: Cannot add or update a child row: a foreign key constraint fails (`www_main/civicrm_value_medical_dietary_needs_3`, CONSTRAINT `FK_civicrm_value_medical_dietary_needs_3_entity_id` FOREIGN KEY (`entity_id`) REFERENCES `civicrm_event` (`id`) ON DELETE CASCADE), 1452

Return to home page.

qjensen

  • I post frequently
  • ***
  • Posts: 141
  • Karma: 11
    • Scaled Solutions
  • CiviCRM version: 4.5
  • CMS version: Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Help with a database error
April 01, 2010, 02:36:18 am
I am having the same issue but posted in a separate thread because I didn't read this one first.

If you have a custom data type for Participants, the FK should be on participant ID, not event ID. Somehow when the custom data table was created, it was created with the wrong FK constraint.

I did a show create table tablename in phpMyAdmin to get the SQL to create the table and then dropped the table. I edited the SQL to have the correct FK and then recreated the table. I did this on a test server, not on the production server, but it seemed to solve the problem.

I have not heard back from anyone regarding the possible side effects of doing this, so I would not suggest it without a solid backup of your data. If I learn anything else, I will let you know.

Q
Quint Jensen
Web Developer
Scaled Solutions
--" Remove the 'I want you to like me' notes from your forehead and place them where they truly will do the most good -- on your mirror!" Author Unknown

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviEvent (Moderator: Yashodha Chaku) »
  • Help with a database error

This forum was archived on 2017-11-26.