I developed a CSV data importer for my mysql
base.
The feature is working properly, however I believe you should have a better way to implement the following logic.
In the CSV file depending on whether or not 2 inserts (master-detail) can occur, the only way I can control them is through their PK self-increment.
What I do - I make an insert, if there is such detail information, I retrieve the last insert (select max(id) table
, or with the function LAST_INSERT_ID()
and save the information retrieved in my tbl of detail.
As my service is online, and other people can perform the same import procedure, the insert event may occur on the same team and my operation is no longer trusted.
> One way I thought, and I'm researching is, as mysql
already knows what the next index, I somehow book and block this index and do my procedure, if something happens it will proceed with the next line .
Has anyone ever worked with this problem?