MySQL Forums
Forum List  »  Knowledge Base

About LAST_INSERT_ID()
Posted by: Halwa Raj
Date: March 15, 2009 11:55AM

The reference Manual says above function returns the first auto generated value for an auto incrementing column.

I have a database with a few tables. Now, there is a table "TABLE 1", the PK of which i use as FK in other tables.

Now, My worry is, How do i handle this situation?

I tried using LAST_INSERT_ID() that also did not help(no table or DB lock used). The data got corrupted.

Suppose the AI id for one req was 6. Before the application could make a call to get the ID, other request was executed and the AI id returned was not correct.

Now, the only option left out is to lock the table or DB and do the processing and thts how I can proceed.

Just wanted to know if there is som other way to do this.

Also, what lock should i Use table lock or DB lock? and approx. how much of a performance hit would it be?

Other points to remeber:
There are possibilities of simultaneous hits.
This app needs to sclable. At any given point of time, around 100 users would be online.

Options: ReplyQuote


Subject
Views
Written By
Posted
About LAST_INSERT_ID()
3066
March 15, 2009 11:55AM


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.