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 CiviContribute (Moderator: Donald Lobo) »
  • DB Error: constraint violation: Wordpress
Pages: [1]

Author Topic: DB Error: constraint violation: Wordpress  (Read 875 times)

Interpolat

  • I post frequently
  • ***
  • Posts: 140
  • Karma: -1
    • Interpolat Solutions, LLC.
  • CiviCRM version: 4.4+
  • CMS version: Wordpress
  • MySQL version: 5.5+
  • PHP version: 5.4+
DB Error: constraint violation: Wordpress
August 22, 2012, 09:15:48 am
I am using CiviCRM 4.2.0 (Stable) on Wordpress 3.4.1.  When I try to process a contribution, I am getting a DB Error:  constraint violation message with the following details:

Quote
Database Error Code: Cannot add or update a child row: a foreign key constraint fails (`mydbname_civicrm`.`civicrm_line_item`, CONSTRAINT `FK_civicrm_line_item_price_field_id` FOREIGN KEY (`price_field_id`) REFERENCES `civicrm_price_field` (`id`) ON DELETE CASCADE), 1452
Additional Details:
Array
(
    [callback] => Array
        (
           
  • => CRM_Core_Error
  • [1] => handle
            )

       
Code: [Select]
=> -3
    [message] => DB Error: constraint violation
    [mode] => 16
    [debug_info] => INSERT INTO civicrm_line_item (entity_table , entity_id , unit_price , line_total ) VALUES ('civicrm_contribution' ,  105 ,  5.00 ,  5.00 )  [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`mydbname_civicrm`.`civicrm_line_item`, CONSTRAINT `FK_civicrm_line_item_price_field_id` FOREIGN KEY (`price_field_id`) REFERENCES `civicrm_price_field` (`id`) ON DELETE CASCADE)]
    [type] => DB_Error
    [user_info] => INSERT INTO civicrm_line_item (entity_table , entity_id , unit_price , line_total ) VALUES ('civicrm_contribution' ,  105 ,  5.00 ,  5.00 )  [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`mydbname_civicrm`.`civicrm_line_item`, CONSTRAINT `FK_civicrm_line_item_price_field_id` FOREIGN KEY (`price_field_id`) REFERENCES `civicrm_price_field` (`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_line_item (entity_table , entity_id , unit_price , line_total ) VALUES ('civicrm_contribution' ,  105 ,  5.00 ,  5.00 )  [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`mydbname_civicrm`.`civicrm_line_item`, CONSTRAINT `FK_civicrm_line_item_price_field_id` FOREIGN KEY (`price_field_id`) REFERENCES `civicrm_price_field` (`id`) ON DELETE CASCADE)]"]
)
[/quote]

I need help ASAP.  THis is a live site.
Interpolat Solutions, LLC
Connecting the dots for you!
http://www.interpolat.com

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: DB Error: constraint violation: Wordpress
August 22, 2012, 12:02:08 pm
It is erring on this constraint:

Code: [Select]
FOREIGN KEY (`price_field_id`) REFERENCES `civicrm_price_field` (`id`)
Did you delete any price fields?
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

Interpolat

  • I post frequently
  • ***
  • Posts: 140
  • Karma: -1
    • Interpolat Solutions, LLC.
  • CiviCRM version: 4.4+
  • CMS version: Wordpress
  • MySQL version: 5.5+
  • PHP version: 5.4+
Re: DB Error: constraint violation: Wordpress
August 22, 2012, 02:40:04 pm
Actually, no, I do not believe I did.  At least not intentionally!
« Last Edit: August 22, 2012, 02:42:32 pm by jmdziba »
Interpolat Solutions, LLC
Connecting the dots for you!
http://www.interpolat.com

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: DB Error: constraint violation: Wordpress
August 23, 2012, 03:33:18 am
Actually, now that I look at your post more closely, the price_field_id field is not defined in the INSERT:

Code: [Select]
INSERT INTO civicrm_line_item (entity_table , entity_id , unit_price , line_total )
VALUES ('civicrm_contribution' ,  105 ,  5.00 ,  5.00 ) 

and thus it's NULL and thus the error, as it needs to refer to a record in the civicrm_price_field table. Can you try to recreate this on the demo? If so, then it appears to be a bug.

Was your site upgraded or is this a fresh install?
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

Interpolat

  • I post frequently
  • ***
  • Posts: 140
  • Karma: -1
    • Interpolat Solutions, LLC.
  • CiviCRM version: 4.4+
  • CMS version: Wordpress
  • MySQL version: 5.5+
  • PHP version: 5.4+
Re: DB Error: constraint violation: Wordpress
August 23, 2012, 07:41:07 am
Site has gone through several upgrades.  I am not sure which upgrade broke the site, but I would say all was well up until at least 4.2 Beta 1.  Can you suggest a patch to fix this.  I am not quite sure how to recreate this in the demo, since the Price Sets were already defined when the upgrades were done.  So creating new Price Sets in the demo would not be a true recreation of my situation.
« Last Edit: August 23, 2012, 09:44:42 am by jmdziba »
Interpolat Solutions, LLC
Connecting the dots for you!
http://www.interpolat.com

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: DB Error: constraint violation: Wordpress
August 23, 2012, 08:03:47 am
Ah, you upgraded to a Beta version along the way. That may or may not be related.

All I can suggest is to try that page wit a price set and see if that helps....
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

Interpolat

  • I post frequently
  • ***
  • Posts: 140
  • Karma: -1
    • Interpolat Solutions, LLC.
  • CiviCRM version: 4.4+
  • CMS version: Wordpress
  • MySQL version: 5.5+
  • PHP version: 5.4+
Re: DB Error: constraint violation: Wordpress
August 23, 2012, 08:14:14 am
Ok.  So when I submit a donation using one of the Price Set options, the page processes fine.  However, if I choose to enter my own different amount, then I get the error.
Is there a way for me to save just my data, and do a complete new install, and then re-install the data to a new installation of Civi?   
« Last Edit: August 23, 2012, 09:40:08 am by jmdziba »
Interpolat Solutions, LLC
Connecting the dots for you!
http://www.interpolat.com

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviContribute (Moderator: Donald Lobo) »
  • DB Error: constraint violation: Wordpress

This forum was archived on 2017-11-26.