MySQL Forums
Forum List  »  InnoDB

Re: Foreign Key Constraint Fails on Insert During Transaction
Posted by: Sukhwinder Singh
Date: August 06, 2008 07:14PM

I also faced the same problem.

I was using three tables.

start transaction

Insert into category table - get newly inserted id (auto increment) as category_id
Insert into product table - get newly inserted id (auto_increment) as product_id

Insert into product_category (product_id, category_id) (foreign key constraints referring to product.id and category.id) - And it FAILED.

I finally found out that I had renamed the category table to category_old and foreign key in product was still referring to category_old table and not new category table.



Edited 1 time(s). Last edit at 08/07/2008 05:08PM by Sukhwinder Singh.

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Foreign Key Constraint Fails on Insert During Transaction
3914
August 06, 2008 07:14PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.