【发布时间】:2014-10-15 21:34:56
【问题描述】:
我正在尝试使用 Kettle 创建一个转换,它可以从我的数据库中读取一个表,然后连接到远程 postgresql 数据库,将新行插入远程数据库(或者如果值更改则更新,或者如果远程不做任何事情表的数据与我的表相同)。它在插入时工作正常,但是当它尝试更新一行时,我收到以下错误:
Insert / Update.0 - ERROR (version 5.2.0.0, build 1 from 2014-09-30_19-48-28 by buildguy) : Unexpected error
org.pentaho.di.core.exception.KettleStepException:
2014/10/15 16:52:54 - Insert / Update.0 - Error in step, asking everyone to stop because of:
2014/10/15 16:52:54 - Insert / Update.0 - Error inserting/updating row
2014/10/15 16:52:54 - Insert / Update.0 - ERROR: duplicate key value violates unique constraint "test_pentaho_pkey"
2014/10/15 16:52:54 - Insert / Update.0 - Detail: Key (id)=(3) already exists.
我很困惑为什么它尝试插入,因为 id 是主键,所以如果该 id 存在,它应该只更新它,而不是尝试插入它。我该如何解决这个问题?我在插入/更新步骤设置中做错了吗?
这是我在勺子界面上的插入/更新步骤设置:
我的数据库表内容:
id | name | age
----+------------+-----
1 | ioqw | 50
2 | 12132 | 32
4 | test_data1 | 24
5 | test_data1 | 24
6 | hello | 24
3 | hello3 | 50
(6 rows)
远程数据库表内容:
id | name | age
----+------------+-----
1 | ioqw | 50
2 | 12132 | 32
3 | test_data | 14
4 | test_data1 | 24
5 | test_data1 | 24
(5 rows)
我试图用 id=3 更新远程表的行。
【问题讨论】:
-
我的回答对你有用吗?
-
是的,确实如此。谢谢!!
标签: postgresql pentaho etl kettle