SQLBuider how to create dynamic query with Talend Open Studio

550 views Asked by At

I have data in excel file which I want to insert into database table. One of the column (name) is connected with another table from db. I would like to make a simple query according to value from excel and put into table only id.

Sample of excel file:

age       name     position
-------  -------  -------
23        Kate      PWN
36        John      TDF

Sample of table from db:

id        name     
-------  -------  
1         Kate    
2         John   

Table which I would like to put data from excel:

id       name_id  position
-------  -------  -------
1           1      PWN
2           2      TDF

Basically I need to get data from excel file, iterate and make a simple query

SELECT (id) FROM name WHERE name = name_from_excel; 

Then I can put id into proper field in tMap.

tMap where description and value are name

1

There are 1 answers

3
Ibrahim Mezouar On

You can do this with a simple join in Talend:

                DB Input
                    |
                    |  
tFileInputExcel -- tMap -- DB Output

Inside tMap you join the column Name from your excel with the Name column from your table, and insert the columns you want in your target DB