[resolved] Get last insert ID of a specific table

One Star

[resolved] Get last insert ID of a specific table

Hi !
I have a sub-process with 2 simple steps :

Add a new item in the DB
Add links related to this item in a relational table in the DB

Then, I need the last insert ID.
The two steps come from the same source of data. That means I have a tReplicate with two branches : first to insert the value, second to insert the links.
For the second step, I use to put a tMySQLInput, select the content of the table (just ID and name) and match with the data I just inserted (basically, the name).
Obviously, I committed the first action before doing the second one.
But the SELECT doesn't give me the ID. Seems it doesn't get the up-to-date data of the DB.
On another sub-part of the job, I get this ID (one iteration later) and, obviously, I checked that my value is well inserted.
I tried to use the tMySQLLastInsertId component, but I still have the problem : for the same iteration, no value returned.
I used the same MySQL connection, of course.
Any idead will be appreciated !
Thank you !
Moderator

Re: [resolved] Get last insert ID of a specific table

Hi,
Have you checked component t<DB>lastInserted which fetches the last inserted ID from a selected DB Connection?
TalendHelpCenter:tMysqlLastInsertId?
Could you please post your job design screenshots into forum?
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

Re: [resolved] Get last insert ID of a specific table

Hi,
Yes, I tried tMySQLLastInsertID.
Actually, I had the same problem with that component.
I solved my problem by putting this component (tMySQLLastInsertID) right after the tMySQLOutput, and then I have the last ID directly, and I don't have to wait for the next iteration.
Thank you for your answer !
Moderator

Re: [resolved] Get last insert ID of a specific table

Hi,
Thanks for your feedback and set this topic as resolved.
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.