[resolved] Get insert ID

One Star

[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 http://talendforge.org/forum/viewtopic.php?id=4895
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 http://talendforge.org/forum/viewtopic.php?id=4895 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.

Accepted Solutions
One Star

Re: [resolved] Get insert ID

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

All Replies
One Star

Re: [resolved] Get insert ID

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?
One Star

Re: [resolved] Get insert ID

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...
One Star

Re: [resolved] Get insert ID

This problem is solved. Thanks to Mhirt.
In advanced settings Use extended output must be unchecked ! after it, it works Smiley Happy
Community Manager

Re: [resolved] Get insert ID

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.
One Star

Re: [resolved] Get insert ID

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