The fastest running way is to simply have a second subjob where you use the first table as a lookup to get the ID.
The slower way is to make sure both tMysqlOutput components share a connection, in the first uncheck "Extend Insert" and in the second use the "Additional columns" to replace the field that should contain the key with the SQL expression "LAST_INSERT_ID()".
I didn't say to use TmysqlLastInsertId.
But if you are trying to use a value from that component (being on the first output branch from tMap) in a second output table in tMap it won't work, because all tMap output tables are populated before any of the following components are executed instead of only populating each output table immediately before executing the components that use that output - see Jira. Which is why I suggested the approach I did.
Did you read the help on this functionality? The "Name" is the field name in your DB which this SQL expression will populate. The "Reference column" is the column name in your schema used by the "Position". The "Position" is where in your SQL statement to place this SQL expression.
I would be expecting you to "Replace" filterCriteriaId, in which case the Name should also be "filterCriteriaId".
What you are doing is trying to populate a column called "new" with LAST_INSERT_ID() and include that before filterCriteriaId in your SQL statement i.e. INSERT INTO [ChildTable] (lastStatusChange, statusCode, new, filterCriteriaId) VALUES (?,?,LAST_INSERT_ID(),?).
If you look at the code generated, you'll see exactly what effect your changes have on the prepared statement used.
hello , I'm very sorry of the disturbance , it's my first experience with Talend . But when I set the "Position" to "Replace it's generate an error like : Cannot add or update a child row: a foreign key constraint fails (`datadb`.`filtercriteriarepositoryelement`, CONSTRAINT `FK_filterCriteriaId` FOREIGN KEY (`filterCriteriaId`) REFERENCES `filtercriteria` (`filterCriteriaId`) ON DELETE CASCADE ON UPDATE NO AC)
That's an MySQL error and I don't use MySQL but it looks like it's suggesting the FK is invalid. Did you follow my other instructions: make sure both tMysqlOutput components share a connection and uncheck "Extend Insert"?
Test if the filterCriteriaId is being retrieved correctly by replacing your tMysqlOutput with tFlowToIterate -> tMysqlInput (also sharing a connection; "select last_insert_id()") --> tLogRow.
je suis debutant en talend et je voudrais créee une table a partir de talend avec une clé etrangere
mon probleme est que je sais pas comment specifier la contrainte de clé etrangere a partir de tmap
pourriez vous m'aider ???