Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
!!!
You can only get the ID of an existing parent by querying the database. So you can either have a lookup flow from tMysqlInput (rest_tab) to tMap_3 or embed a tMysqlRow and tParseRecordSet before tNormalize_1.
The first is easier and faster but is taking you towards my previous suggestion anyway (which I think was a lot simpler).
OK, so we can take Name and Course as fixed values i.e. use those to look for the record in the table.
But what you want is complicated because of the need to use the parent's ID as a foreign-key when you do an insert but the parent might already exist or you might only be creating it now. I think the best way is to do the parent and child in separate steps.
First, read your file with just Name and Age in the schema, making Name the key field. Pass the flow to tUniqRow to eliminate the duplicates and then to your parent DB table. In the DB output component, set the "Action on data" to "Update or Insert". Now existing Names in the DB will be updated with the new Age and new Names will be inserted (with Age) and the ID generated by the DB.
As the second step, read your file again as the main flow to tMap with a lookup flow from the parent table, joined on Name. In the output, make NAME_ID and Course the key fields with Amount as the other field. In the DB output component, set the "Action on data" to "Update or Insert". Now existing NAME_ID and Course combinations in the DB will be updated with the new Amount and new NAME_ID and Course combinations will be inserted (with Amount) and the ID generated by the DB.
OK, so we can take Name and Course as fixed values i.e. use those to look for the record in the table.
But what you want is complicated because of the need to use the parent's ID as a foreign-key when you do an insert but the parent might already exist or you might only be creating it now. I think the best way is to do the parent and child in separate steps.
First, read your file with just Name and Age in the schema, making Name the key field. Pass the flow to tUniqRow to eliminate the duplicates and then to your parent DB table. In the DB output component, set the "Action on data" to "Update or Insert". Now existing Names in the DB will be updated with the new Age and new Names will be inserted (with Age) and the ID generated by the DB.
As the second step, read your file again as the main flow to tMap with a lookup flow from the parent table, joined on Name. In the output, make NAME_ID and Course the key fields with Amount as the other field. In the DB output component, set the "Action on data" to "Update or Insert". Now existing NAME_ID and Course combinations in the DB will be updated with the new Amount and new NAME_ID and Course combinations will be inserted (with Amount) and the ID generated by the DB.