Answers.Body: <p>It sounds like you have selected one of the columns to be "Master Address Belongs To". If the record that column references doesn't exist yet you will get this error. Also FYI it looks like that column needs to be an integer.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-06-05T22:06:20.043Z
Answers.Text: hence if you have some with a value and some without, try doing as 2 separate imports
Answers.UserDisplayName: petednz - fuzion
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-06-05T03:45:59.367Z
Answers.LastActivityDate: 2019-06-05T03:45:59.367Z
Answers.UserDisplayName: Demerit
Body: <p>I get the following errors while importing a contact CSV file. I hope somebody can help with the issue. Civicrm 5 latest with WP 5 latest and the error is same with both PHP 5 and 7.2.</p>
  
  <pre><code>"Sorry, due to an error, we are unable to fulfill your request at the moment. You may want to contact your administrator or service provider with more details about what action you were performing when this occurred.
  DB Error: constraint violation
  Error Details
  Database Error Code: Cannot add or update a child row: a foreign key constraint fails (`wp_23ye3`.`civicrm_address`, CONSTRAINT `FK_civicrm_address_master_id` FOREIGN KEY (`master_id`) REFERENCES `civicrm_address` (`id`) ON DELETE SET NULL), 1452
  Additional Details:
  Array
  (
      [callback] =&gt; Array
          (
              [0] =&gt; CRM_Core_Error
              [1] =&gt; handle
          )
  
      [code] =&gt; -3
      [message] =&gt; DB Error: constraint violation
      [mode] =&gt; 16
      [debug_info] =&gt; INSERT INTO civicrm_address (contact_id , location_type_id , is_primary , is_billing , street_address , supplemental_address_1 , city , state_province_id , postal_code , country_id , manual_geo_code , master_id ) VALUES ( 10 ,  1 ,  1 ,  0 , 'Lakhimi Nagar Hatigaon' , 'Dispur' , 'Guwahati' ,  1204 , '781006' ,  1101 ,  0 ,  0 )  [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`wp_23ye3`.`civicrm_address`, CONSTRAINT `FK_civicrm_address_master_id` FOREIGN KEY (`master_id`) REFERENCES `civicrm_address` (`id`) ON DELETE SET NULL)]
      [type] =&gt; DB_Error
      [user_info] =&gt; INSERT INTO civicrm_address (contact_id , location_type_id , is_primary , is_billing , street_address , supplemental_address_1 , city , state_province_id , postal_code , country_id , manual_geo_code , master_id ) VALUES ( 10 ,  1 ,  1 ,  0 , 'Lakhimi Nagar Hatigaon' , 'Dispur' , 'Guwahati' ,  1204 , '781006' ,  1101 ,  0 ,  0 )  [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`wp_23ye3`.`civicrm_address`, CONSTRAINT `FK_civicrm_address_master_id` FOREIGN KEY (`master_id`) REFERENCES `civicrm_address` (`id`) ON DELETE SET NULL)]
      [to_string] =&gt; [db_error: message="DB Error: constraint violation" code=-3 mode=callback callback=CRM_Core_Error::handle prefix="" info="INSERT INTO civicrm_address (contact_id , location_type_id , is_primary , is_billing , street_address , supplemental_address_1 , city , state_province_id , postal_code , country_id , manual_geo_code , master_id ) VALUES ( 10 ,  1 ,  1 ,  0 , 'Lakhimi Nagar Hatigaon' , 'Dispur' , 'Guwahati' ,  1204 , '781006' ,  1101 ,  0 ,  0 )  [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`wp_23ye3`.`civicrm_address`, CONSTRAINT `FK_civicrm_address_master_id` FOREIGN KEY (`master_id`) REFERENCES `civicrm_address` (`id`) ON DELETE SET NULL)]"]
  )"
  </code></pre>
  
  <p><a href="https://i.sstatic.net/IIAzp.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/IIAzp.png" alt="Additional Error after enabling debugging"></a></p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-05-31T22:19:11.863Z
Comments.Text: Hmm you are capturing everything except the actual error & actual query - is this from the log or the UI?
Comments.UserDisplayName: eileen
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-06-01T13:26:38.557Z
Comments.Text: Hi, this is from the UI. The actual error is: "Sorry, due to an error, we are unable to fulfill your request at the moment. You may want to contact your administrator or service provider with more details about what action you were performing when this occurred." Then in the detail of the error, I get " Database Error Code: Cannot add or update a child row: a foreign key constraint fails (`wp_23ye3`.`civicrm_address`, CONSTRAINT `FK_civicrm_address_master_id` FOREIGN KEY (`master_id`) REFERENCES `civicrm_address` (`id`) ON DELETE SET NULL), 1452" The some additional details...
Comments.UserDisplayName: Jayanta Sarma
Tags: <contacts><import>
Title: Problem Importing Contacts
ThreadText: # Problem Importing Contacts
  
  (Asked by: username_0 on 2019-05-31)
  
  I get the following errors while importing a contact CSV file. I hope somebody can help with the issue. Civicrm 5 latest with WP 5 latest and the error is same with both PHP 5 and 7.2.
  "Sorry, due to an error, we are unable to fulfill your request at the moment. You may want to contact your administrator or service provider with more details about what action you were performing when this occurred.
  DB Error: constraint violation
  Error Details
  Database Error Code: Cannot add or update a child row: a foreign key constraint fails (`wp_23ye3`.`civicrm_address`, CONSTRAINT `FK_civicrm_address_master_id` FOREIGN KEY (`master_id`) REFERENCES `civicrm_address` (`id`) ON DELETE SET NULL), 1452
  Additional Details:
  Array
  (
      [callback] => Array
          (
              [0] => CRM_Core_Error
              [1] => handle
          )
  
      [code] => -3
      [message] => DB Error: constraint violation
      [mode] => 16
      [debug_info] => INSERT INTO civicrm_address (contact_id , location_type_id , is_primary , is_billing , street_address , supplemental_address_1 , city , state_province_id , postal_code , country_id , manual_geo_code , master_id ) VALUES ( 10 ,  1 ,  1 ,  0 , 'Lakhimi Nagar Hatigaon' , 'Dispur' , 'Guwahati' ,  1204 , '781006' ,  1101 ,  0 ,  0 )  [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`wp_23ye3`.`civicrm_address`, CONSTRAINT `FK_civicrm_address_master_id` FOREIGN KEY (`master_id`) REFERENCES `civicrm_address` (`id`) ON DELETE SET NULL)]
      [type] => DB_Error
      [user_info] => INSERT INTO civicrm_address (contact_id , location_type_id , is_primary , is_billing , street_address , supplemental_address_1 , city , state_province_id , postal_code , country_id , manual_geo_code , master_id ) VALUES ( 10 ,  1 ,  1 ,  0 , 'Lakhimi Nagar Hatigaon' , 'Dispur' , 'Guwahati' ,  1204 , '781006' ,  1101 ,  0 ,  0 )  [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`wp_23ye3`.`civicrm_address`, CONSTRAINT `FK_civicrm_address_master_id` FOREIGN KEY (`master_id`) REFERENCES `civicrm_address` (`id`) ON DELETE SET NULL)]
      [to_string] => [db_error: message="DB Error: constraint violation" code=-3 mode=callback callback=CRM_Core_Error::handle prefix="" info="INSERT INTO civicrm_address (contact_id , location_type_id , is_primary , is_billing , street_address , supplemental_address_1 , city , state_province_id , postal_code , country_id , manual_geo_code , master_id ) VALUES ( 10 ,  1 ,  1 ,  0 , 'Lakhimi Nagar Hatigaon' , 'Dispur' , 'Guwahati' ,  1204 , '781006' ,  1101 ,  0 ,  0 )  [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`wp_23ye3`.`civicrm_address`, CONSTRAINT `FK_civicrm_address_master_id` FOREIGN KEY (`master_id`) REFERENCES `civicrm_address` (`id`) ON DELETE SET NULL)]"]
  )"
  
  **Tags:** contacts, import
  
  > **Comments:**
  > **username_1**: Hmm you are capturing everything except the actual error & actual query - is this from the log or the UI?  
  > **username_0**: Hi, this is from the UI. The actual error is: "Sorry, due to an error, we are unable to fulfill your request at the moment. You may want to contact your administrator or service provider with more details about what action you were performing when this occurred." Then in the detail of the error, I get " Database Error Code: Cannot add or update a child row: a foreign key constraint fails (`wp_23ye3`.`civicrm_address`, CONSTRAINT `FK_civicrm_address_master_id` FOREIGN KEY (`master_id`) REFERENCES `civicrm_address` (`id`) ON DELETE SET NULL), 1452" The some additional details...  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2019-06-05. Score: 2
  
  It sounds like you have selected one of the columns to be "Master Address Belongs To". If the record that column references doesn't exist yet you will get this error. Also FYI it looks like that column needs to be an integer.
  
  > **Comments:**
  > **username_3**: hence if you have some with a value and some without, try doing as 2 separate imports  
  
  ---
  
  