Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] Get insert ID

Hello,
I have a file and insert row in a mysql table.
After it, i want get for each row the insert id because i need it for many associated tables.
I have tryed TMysqlLastInsertId with this example https://community.talend.com/t5/Design-and-Development/resolved-MySQL-last-insert-id/td-p/1775
but if i understand it give only last insert id of previous job and in more i don't unsertand why i insert 166 rows and lastinsertid give me id = 101.
Same if it works i have many tables as it so can't use this method i think. So please there is not another good way for it?

Bonjour,
J'insère des lignes d'un fichier dans une table MYSQL.
Pour ces lignes certaines colonnes sont insérées dans une table et d'autres dans d'autres tables en prenant soin de récupérer l'ID inséré dans la première table.
Pour cela j'ai essayé la solution donné ici https://community.talend.com/t5/Design-and-Development/resolved-MySQL-last-insert-id/td-p/1775 mais je ne comprends pourquoi le lasinsert id retourné est toujours 101 alors que le job me met bien 166 enregistrements en table.
De plus cette méthode ne m'est pas pratique du tout car je dispose d'un certain nombre de tables associées et je ne vais pas scanner pour chaque table le même fichier en incrément à partir de l'id de début que j'aurai pu obtenir, ce pour toutes les tables dont j'ai besoin. N'auriez vous donc pas s'il vous plait une méthode qui me serait plus appropriée ? et pourquoi LastInsert Id me retourne une valeur inférieur, de plus ((Integer)globalMap.get("tMysqlOutput_3_NB_LINE")) me retourne 0.
Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

This problem is solved. Thanks to Mhirt.
In advanced settings Use extended output must be unchecked ! after it, it works 0683p000009MACn.png

View solution in original post

5 Replies
Anonymous
Not applicable
Author

I finally exactly what i want in TalendIntegrationSuite_Componements documentation in tMysqlLastInsertId (page 305 in french edition), but i don't understand why TLogRow return me always 0 for lastinsertId.
In mysqlOutput i use the good TmysqlConnection.
Someone could help me please?
Anonymous
Not applicable
Author

I have found in documentation (page 301 in french) a better way to get my last id but i don't unsterdand why it doesnt give me the last id for each row but the last id for all rows.
As it if i run one time my 2 rows it gives me in child table id=1 and id=1 , if i run again it give me in child table id=3 and id=3, so it's not good.
Look the screenshot. I think all is ok. I don't understand...
Anonymous
Not applicable
Author

This problem is solved. Thanks to Mhirt.
In advanced settings Use extended output must be unchecked ! after it, it works 0683p000009MACn.png
Anonymous
Not applicable
Author

We'll add a note in the tGetLastInsertId properties description in the next release of the documentation, to explain that the use of the "extended output" option in tMySQLOutput components is not compatible with the use of this component, as the extended output means that the data get loaded by batch into the database, thus only the last batch id is returned.
Cheers,
The doc team.
_AnonymousUser
Specialist III
Specialist III

J'ai beau décocher la case, cela ne fonctionne pas...
Y'a-t-il une autre astuce ??
Merci !! 0683p000009MACn.png