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 Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Duplicate Entry random error
Pages: [1]

Author Topic: Duplicate Entry random error  (Read 1728 times)

prickeke

  • I post occasionally
  • **
  • Posts: 64
  • Karma: 4
Duplicate Entry random error
June 04, 2007, 10:17:52 pm
I got this unrecoverable error when editing a contact...His primary contact info didn't have an e-mail but his additional contact info did.  I copied that e-mail to his primary contact info and saved it only to get the error below.  I deleted the e-mail from his alternative info, then saved.  Then copied it back to his primary info and saved and it worked.  No one else has this e-mail.  This is just weird to me.  Anyone have any ideas?

Sorry. A non-recoverable error has occurred.

    Database Error Code: Duplicate entry 'civicrm_contact-1205-1' for key 2, 1062

    Return to CiviCRM menu.

Error Details:

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

       
Code: [Select]
=> -5
    [message] => DB Error: already exists
    [mode] => 16
    [debug_info] => UPDATE  civicrm_location  SET entity_table = 'civicrm_contact' , entity_id = 1205 , location_type_id = 1 , is_primary = 1 , name = ''   WHERE (  civicrm_location.id = 1931 )   [nativecode=1062 ** Duplicate entry 'civicrm_contact-1205-1' for key 2]
    [type] => DB_Error
    [user_info] => UPDATE  civicrm_location  SET entity_table = 'civicrm_contact' , entity_id = 1205 , location_type_id = 1 , is_primary = 1 , name = ''   WHERE (  civicrm_location.id = 1931 )   [nativecode=1062 ** Duplicate entry 'civicrm_contact-1205-1' for key 2]
    [to_string] => [db_error: message="DB Error: already exists" code=-5 mode=callback callback=CRM_Core_Error::handle prefix="" info="UPDATE  civicrm_location  SET entity_table = 'civicrm_contact' , entity_id = 1205 , location_type_id = 1 , is_primary = 1 , name = ''   WHERE (  civicrm_location.id = 1931 )   [nativecode=1062 ** Duplicate entry 'civicrm_contact-1205-1' for key 2]"]
)

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: Duplicate Entry random error
June 05, 2007, 03:23:23 am

can u try to create a similar scenario on demo and replicate it there. If so, please file an issue and give exact steps to replicate

A unique index constraint is being violated and hence the failure. If you can replicate it on demo, we can fix it :)

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

prickeke

  • I post occasionally
  • **
  • Posts: 64
  • Karma: 4
Re: Duplicate Entry random error
June 05, 2007, 10:50:53 am
Okay,

I duplicated it on the demo server.  My steps and error are listed below.  I don't know if all of the steps/items are required (like having two e-mails in the original location info) but I was trying to replicate the original contact I had.

1. Create New individual -- Entered first name, last name, e-mail 1, e-mail 2, 1 tag, save.
2. Edit same individual -- add additional location (I chose billing, but don't think it matters) -- no e-mail, address 1 (street 1, city, state, country), make new location primary, save.
3. Edit individual again, delete e-mail 1 (from original, but now additional location), leave e-mail 2 where it is.  Paste e-mail 1 into new primary location.  Change primary location to Home, change additional location to Other, Save.

ERROR:

Code: [Select]
     Sorry. A non-recoverable error has occurred.

    Database Error Code: Duplicate entry 'civicrm_contact-1067-1' for key 2, 1062

    Return to CiviCRM menu.

Error Details:

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

    [code] => -5
    [message] => DB Error: already exists
    [mode] => 16
    [debug_info] => UPDATE  civicrm_location  SET entity_table = 'civicrm_contact' , entity_id = 1067 , location_type_id = 1 , is_primary = 1 , name = ''   WHERE (  civicrm_location.id = 1080 )   [nativecode=1062 ** Duplicate entry 'civicrm_contact-1067-1' for key 2]
    [type] => DB_Error
    [user_info] => UPDATE  civicrm_location  SET entity_table = 'civicrm_contact' , entity_id = 1067 , location_type_id = 1 , is_primary = 1 , name = ''   WHERE (  civicrm_location.id = 1080 )   [nativecode=1062 ** Duplicate entry 'civicrm_contact-1067-1' for key 2]
    [to_string] => [db_error: message="DB Error: already exists" code=-5 mode=callback callback=CRM_Core_Error::handle prefix="" info="UPDATE  civicrm_location  SET entity_table = 'civicrm_contact' , entity_id = 1067 , location_type_id = 1 , is_primary = 1 , name = ''   WHERE (  civicrm_location.id = 1080 )   [nativecode=1062 ** Duplicate entry 'civicrm_contact-1067-1' for key 2]"]
)

[/code]

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Duplicate Entry random error
June 08, 2007, 03:42:51 pm
Keith - After several attempts to narrow this down, I've determined that the error you're seeing is caused by swapping the location types in your 3rd step. The code is trying to update your primary location "type" to Home - but your additional location is still set to Home in the DB (the update to "Other" hasn't happened "yet") - and there is a UNIQUE key on contact+location_type.

I've filed a bug report for 1.8 for this case - hopefully we can figure out a way to order the updates to prevent the key conflict.
http://issues.civicrm.org/jira/browse/CRM-1986
Protect your investment in CiviCRM by  becoming a Member!

prickeke

  • I post occasionally
  • **
  • Posts: 64
  • Karma: 4
Re: Duplicate Entry random error
June 18, 2007, 01:25:46 pm
Great!  I'll try to remember the swapping thing when I update things in the future.

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: Duplicate Entry random error
June 18, 2007, 07:28:10 pm

Keith:

Note that the swapping thing is fixed in CiviCRM v1.8 :)

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

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Duplicate Entry random error

This forum was archived on 2017-11-26.