MySQL Forums
Forum List  »  Connector/Python

Re: mysql transactions - foreign key failure (update: actually LAST_INSERT_ID() issue)
Posted by: Aaron Peachey
Date: September 27, 2009 06:40AM

OK, I've done some more traces in my code and found the reason for the foreign key errors is actually that my "select LAST_INSERT_ID()" is returning the total number of rows in the table + 1, not the id generated by the auto-increment.

e.g.
I insert a row which will atuo-increment to 227 but there are only 219 rows in the table so the LAST_INSERT_ID() is coming back as 220.
Any idea why and how to fix this?

thanks again
Aaron

Options: ReplyQuote


Subject
Written By
Posted
Re: mysql transactions - foreign key failure (update: actually LAST_INSERT_ID() issue)
September 27, 2009 06:40AM


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.