如何在Pentaho的数据库中实现添加(如果不可用)?

时间:2017-01-01 22:50:00

标签: pentaho pentaho-spoon

如何实现或使用哪些步骤创建比较表和列表的转换。例如,数据库表名称Schools和具有大量学校名称列表的excel文件。

如果在数据库中没有看到excel中的条目,则应将其添加到数据库表中。

我不太确定我是否可以使用数据库查找步骤,但它不会判断查找是否失败。插入更新步骤似乎也不是一个解决方案,因为它需要一些ID值,但excel文件中的学校列表中没有ID

2 个答案:

答案 0 :(得分:1)

根据您提供的信息,使用表插入步骤的简单连接将完成您的任务。您可以使用Merge rows步骤比较数据流(excel和数据库)。合并行步骤使用键来比较两个流,并添加一个标记字段,将该行标记为new, identical, changed, deleted。在您的情况下,您希望通过使用表插入步骤插入标记为新的所有行。

请查看以下链接以获取更多参考。

Merge rowsSynchronize after merge

答案 1 :(得分:0)

这对我有用,

excel file --> 
select values (to delete unnecessary fields) -->
database lookup (this will create a new field, and will set null if not found)     -->
filter rows (get the fields with null output from lookup) -->
table output (insert the filtered records)