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 »
  • Installing CiviCRM »
  • Drupal Installations (Moderator: Piotr Szotkowski) »
  • DB Error: constraint violation
Pages: [1]

Author Topic: DB Error: constraint violation  (Read 2030 times)

est

  • Guest
DB Error: constraint violation
July 07, 2009, 11:46:09 pm
Drupal 6.13, CiviCRM 2.2.7

I've got unrecoverable error message trying to create new mailing.

Code: [Select]
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 (`civicrm/civicrm_mailing`, CONSTRAINT `FK_civicrm_mailing_created_id` FOREIGN KEY (`created_id`) REFERENCES `civicrm_contact` (`id`) ON DELETE CASCADE), 1452

Return to home page.

Error Details:

Array
(
    [callback] => Array
        (
            [0] => CRM_Core_Error
            [1] => handle
        )

    [code] => -3
    [message] => DB Error: constraint violation
    [mode] => 16
    [debug_info] => INSERT INTO civicrm_mailing (name , created_id ) VALUES ('test' ,  102 )  [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`civicrm/civicrm_mailing`, CONSTRAINT `FK_civicrm_mailing_created_id` FOREIGN KEY (`created_id`) REFERENCES `civicrm_contact` (`id`) ON DELETE CASCADE)]
    [type] => DB_Error
    [user_info] => INSERT INTO civicrm_mailing (name , created_id ) VALUES ('test' ,  102 )  [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`civicrm/civicrm_mailing`, CONSTRAINT `FK_civicrm_mailing_created_id` FOREIGN KEY (`created_id`) REFERENCES `civicrm_contact` (`id`) ON DELETE CASCADE)]
    [to_string] => [db_error: message="DB Error: constraint violation" code=-3 mode=callback callback=CRM_Core_Error::handle prefix="" info="INSERT INTO civicrm_mailing (name , created_id ) VALUES ('test' ,  102 )  [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`civicrm/civicrm_mailing`, CONSTRAINT `FK_civicrm_mailing_created_id` FOREIGN KEY (`created_id`) REFERENCES `civicrm_contact` (`id`) ON DELETE CASCADE)]"]
)
[/code]
« Last Edit: July 07, 2009, 11:48:11 pm by est »

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: DB Error: constraint violation
July 08, 2009, 07:46:52 am

your session seems to be out of sync from the db (did u reload the db?)

can u truncate your session table or logout and log back in

thanx

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

est

  • Guest
Re: DB Error: constraint violation
July 08, 2009, 02:32:22 pm
I cleared cache, logged out and logged in and it's working now.

Thank you!

dcrane

  • Guest
Re: DB Error: constraint violation
July 19, 2009, 06:55:19 pm
I'm having the same problem.  I just enabled CiviCRM in my Drupal 6.13 system. The error occurs when someone tries to create a new account. CiviCRM adds several account fields, including first and last name. That seems to be where it blows up.  The account is created, but the extra fields are not there.

My Drupal cache is not enabled. Do I need to reinstall CiviCRM or is there a simpler solution?  

BTW, I checked drupal_root/sites/xxx/civicrm.settings.php and the DB name is correct. I also enabled debug in CiviCRM and used the command '&directoryCleanup=3'  No change.
« Last Edit: July 19, 2009, 07:35:06 pm by dcrane »

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
Re: DB Error: constraint violation
July 20, 2009, 12:10:09 am
Are you sure it's the same message? It seems odd to get a mailing-related issue when creating an account

dcrane

  • Guest
Re: DB Error: constraint violation
July 20, 2009, 07:30:45 am
Quote from: ken on July 20, 2009, 12:10:09 am
Are you sure it's the same message? It seems odd to get a mailing-related issue when creating an account
Here's the message:
"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 (`drupal/civicrm_log`, CONSTRAINT `FK_civicrm_log_modified_id` FOREIGN KEY (`modified_id`) REFERENCES `___temp_host_restore_20090716_152146`.`civicrm_contact` (`id`) ON DELETE CASCADE), 1452"

The Drupal system does send an e-mail to each new registrant.  In this case, the new user is created, but the e-mail never arrives,  However, the new user record does not have the CiviCRM fields (first & last name, address, etc,)
« Last Edit: July 20, 2009, 08:19:48 am by dcrane »

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
Re: DB Error: constraint violation
July 20, 2009, 03:06:32 pm
OK it is a different message. It's a foreign key constraint, but on a different table, namely the civicrm_log.

When I search the forums for "FK_civicrm_log_modified_id" I see a number of people have had the same error under various conditions. Do any of those help? (A couple seem to be related to syncing users between the CMS and CiviCRM, which sounds like it may be related to your situation?)

Ken
« Last Edit: July 20, 2009, 03:08:31 pm by ken »

dcrane

  • Guest
Re: DB Error: constraint violation
July 20, 2009, 05:07:19 pm
Quote from: ken on July 20, 2009, 03:06:32 pm
A couple seem to be related to syncing users between the CMS and CiviCRM, which sounds like it may be related to your situation?)
It does appear to be a sync problem, but none of those seem to be related to mine.  I'll bite the bullet, delete CiviCRM, and re-install it.

PS: Re-installing 2.2 solved the problem.
« Last Edit: July 20, 2009, 06:08:17 pm by dcrane »

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Installing CiviCRM »
  • Drupal Installations (Moderator: Piotr Szotkowski) »
  • DB Error: constraint violation

This forum was archived on 2017-11-26.