简体   繁体   中英

Database lookup in Talend

In my talned job I am copying data from Excel to SQL table. For this job to maintain the foreign key constraint I had to do a look up before copying the data.

The task goes like this. I have to copy data in Table2 (id keys value). My excel sheet has data for id and keys column. Table 1 has two columns id and value.

For value column's data I want to look at Table1's corresponding entry with the id of the current record in Table2. I have to copy the data from Table1's value column to Table2's value column.

Excel (id 1 2 3, keys abc) Table_1 (id 1 2 3, value 123 456 789) desired output: Table_2 (id 1 2 3, keys abc, value 123 456 789) current output: Table_2 (id 1 2 3, keys abc, value null null null)

How do I properly map this?

在此处输入图片说明在此处输入图片说明

You've set the job up exactly as needs to be done really so it's not your job layout that's the problem here.

If you're expecting every record in your Excel document to have a matching record in your database table then you should use an inner join condition in your tMap join like so:

tMap中的加入条件

And this then allows you to have an output that grabs everything that isn't joining (which is your issue here):

加入拒绝配置

This should show you everything in your source (not lookup) file that isn't matching. I suspect that everything is failing to match on your join condition (essentially WHERE ExcelDoc.id = Table.Id ) even if it looks like it should. This could be down to a mismatch of datatypes as they are read into Talend (so the Java/Talend datatypes such as int/Integer or String rather than the DB types) or because one of your id columns has extraneous whitespace padding.

If you find that your id column in one of your sources does in fact have any padding then you should be able to convert it in a previous step before your join or even just make the transformation in the join:

转换联接本身中的输入

The only other thing I'd recommend is that you name your flows between components (just click on them to change the name), especially when you are joining anything in a tMap.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM