当前位置:网站首页>db2中kettle报错 Field [XXX] is required and couldn‘t be found 解决方法
db2中kettle报错 Field [XXX] is required and couldn‘t be found 解决方法
2022-08-04 02:43:00 【追逐梦想永不停】
一、前言
有一个需求,要从db2的某个表抽取数据到mysql的某个表中。
准备用kettle实现,由于数据来源是db2,因此要先写db2的sql语句,样例如下:
select
user_name as name,
concat(modifydate, concat(' ',modifytime)) as last_modified_date
from myschema.mytable
然后,mysql里的目标表中,使用了:
<value>
<name>name</name>
<rename>name</rename>
<update>Y</update>
</value>
<value>
<name>last_modified_date</name>
<rename>last_modified_date</rename>
<update>Y</update>
</value>
结果,执行时报错:
Field [name] is required and couldn't be found
上面明明配置了as name,但是还报错没有name,就很奇葩。
二、解决方法
1.点击kettle里的获取和更新字段试了下,发现如果sql是上面样的,那么自动生成的字段如下:
<value>
<name>user_name</name>
<rename>user_name</rename>
<update>Y</update>
</value>
<value>
<name>last_modified_date</name>
<rename>last_modified_date</rename>
<update>Y</update>
</value>
也就是说,db2里的sql,写了个user_name as name,但是没有生效。
这样也行,但是还是别扭,为什么as没有生效呢?
2.于是,修改sql为:
select
trim(user_name) as name,
concat(modifydate, concat(' ',modifytime)) as last_modified_date
from myschema.mytable
加了一个trim,终于,不报错了。
所以结论就是,kettle里写db2的sql时,如果只用as,是不会生效的;
必须加些处理方法,例如trim()。(虽然不知道为什么)
三、备注
1.如果使用kettle连接db2数据库时,报错没有驱动,就把db2jcc4-9.7.0.6.jar放到\data-integration\lib下,重启kettle即可。(这个就是连接db2用的jar包)
2.kettle连接db2数据库,使用的sql中,使用limit没有生效:fetch first 10 rows only,运行后还是会查全部数据,不确定是为什么。
边栏推荐
- Simple record of Flink principle flow chart
- There are n steps in total, and you can go up to 1 or 2 steps each time. How many ways are there?
- MySQL高级-读写分离-分库分表
- DDTL: Domain Transfer Learning at a Distance
- [QNX Hypervisor 2.2用户手册]10.3 vdev gic
- C语言--环形缓存区
- 编写 BOLL 心得体会
- Priority_queue element as a pointer, the overloaded operators
- Example: 036 is a prime number
- DHCP服务详解
猜你喜欢
随机推荐
DHCP服务详解
Kubernetes:(十一)KubeSphere的介绍和安装(华丽的篇章)
Pine Script | How to display and typeset a plot switch?
Why use Selenium for automated testing
The browser
SAP SD模块前台操作
flinkcdc 消费 mysql binlog 没有 sqltype=delete 的数据是什么原
mpf5_定价Bond_yield curve_Spot coupon_duration_有效利率_连续复利_远期_Vasicek短期_CIR模型Derivatives_Tridiagonal_ppf
[Study Notes Dish Dog Learning C] Dynamic Memory Management
STM8S105K4T6------串口发送和接收
STM8S105K4T6------Serial port sending and receiving
There are n steps in total, and you can go up to 1 or 2 steps each time. How many ways are there?
WPE详细教程
Qt中对象树的机制介绍以及底层实现,各种结果分析:(以及自己写容易犯错的点)
[Playwright Test Tutorial] 5 minutes to get started
keytool命令
Flink原理流程图简单记录
Rongyun "Audio and Video Architecture Practice" technical session [complete PPT included]
Parquet encoding
关联接口测试









