Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8680665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:18:28+00:00 2026-06-12T21:18:28+00:00

Continuing to the post of reading-from-XML-and-storing-the-values-in-database-using-grails am facing an another problem in it. As

  • 0

Continuing to the post of reading-from-XML-and-storing-the-values-in-database-using-grails

am facing an another problem in it. As the employee id is related to other tables as foreign key how am suppose to insert the data into the database without conflict what i want to add in grails code to avoid the below displayed error.

com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException:Cannot
add or update a child rowL a foreign key constraint fails.. ( CONSTRAINT ‘EMPLOYEE_ID_HEADER’
FOREIGN KEY (‘EMPLOYEE_ID’) REFERENCES ’employee_header'(’employee_id’))

here employee_id is a column and employee_header is a separate table that contains employee_id as a foreign key.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T21:18:29+00:00Added an answer on June 12, 2026 at 9:18 pm

    Finally I got the answer, when you are inserting the values in database the related foreign key tables will get affects initially. So to handle this situation we have to insert the foreign key related table at first then the table we need to add exactly.

    For the reference, at first I had given the code like this

    sql.executeInsert("insert into order_item (order_id,product_id,
    order_item_seq_id) values (${order_id},${product_id},${order_item_seq_id})")

    sql.executeInsert("insert into product(product_id) values(${product_id})")

    This first inserts the order_item table then the foreignkey constraint table product, so the data did not inserted. So the correct code is

    sql.executeInsert("insert into order_header(order_id) values(${order_id})")
    sql.executeInsert("insert into product(product_id) values(${product_id})")
    sql.executeInsert("insert into order_item (order_id,product_id,
    order_item_seq_id) values (${order_id},${product_id},${order_item_seq_id})")

    Now this inserts the data successfully without errors.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am facing a continuing problem distinguishing delegation, composition and aggregation from each other,
Continuing off this post: Performance hit incurred using NSMutableDictionary vs. NSMutableArray> I am trying
Continuing my previous post, upload file with relative path I tried to run using
im using Views to output a block, containing latest post titles - simple and
Continuing from this question : When I am trying to do fopen on Windows,
Continuing my quest to perform a dropbox query I am using http-conduit to try
Continuing from my earlier question , how can I combine the month, day, and
I am reading an apache logfile using read.table and am wondering if it's somehow
I'm continuing a previous post , but I thought I'd open a new thread
So the gist is that I need to post XML data query to a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.