title: getting ERROR 1452 (23000) if inserting csv file from shell script code
body: <p>This is my shell script to insert  csv data into my mysql table but we are getting the below error. </p>
  
  <blockquote>
    <p>"ERROR 1452 (23000) at line 1: Cannot add or update a child row: a
    foreign key constraint fails (<code>inv_impact</code>.<code>asset_ext_warranty</code>,
    CONSTRAINT <code>fk_asset_ext_warranty</code> FOREIGN KEY (<code>vendor_id</code>)
    REFERENCES <code>vendor</code> (<code>vendor_id</code>) ON DELETE NO ACTION ON UPDATE NO
    ACTION)"</p>
  </blockquote>
  
  <p>Shell script is like:</p>
  
  <pre><code>#!/bin/bash
  IFS=,
  while read offering auth_no DOP price extend_from extend_to status vendor_id
  do echo "INSERT INTO asset_ext_warranty(offering, auth_no, DOP, price, extend_from, extend_upto, status, vendor_id) VALUES ('$offering','$auth_no','$DOP','$price','$extend_from','$extend_upto','$status','$vendor_id');"  done &lt; warr-ext.csv | mysql -uroot -p'pass' dbname;
  </code></pre>
  
  <p>while the parents table has the vendor_id with the referencing values</p>
  
  <pre><code>vendor_id | vendor_name                | person_name        | phone_no      | mail_id                   | vendor_detail                                                                      |
  +-----------+----------------------------+--------------------+---------------+---------------------------+------------------------------------------------------------------------------------+
  |         1 | nsiah              | Hshiwq      | 0981002364   | suajs@yahoo.co.in | NULL                                                                               |
  |         2 | Dell International service | Dell               | 1800-425-4026 | NULL                      | NULL                                                                               |
  |         3 | Integral system ltd        | Mamata             | NULL          | NULL                      | NULL
  </code></pre>
  
  <p>the child row(vendor_id) in <em>csv</em> file has the same value as parents row .</p>