如何使用Talend从数据库的列中获取文本的一部分,然后使用tdbnput进行打印。

huangapple go评论76阅读模式
英文:

how to get a part of a text from a column in the database using tdbnput and print in talend

问题

我有一个类似上面的Talend作业,我正在使用SELECT语句从Oracle访问数据:

select id, name, details from employee;

然后通过电子邮件发送结果。然而,对于一个特定的“details”列,它有10行不同的动态内容,还有其他各种不需要的/无关的信息,我想精确地筛选出其中的几行并将它们使用TJava组件打印到邮件中。

我该如何做到这一点?

例如,“details”列有如下值:
“嗨,我是约翰
我在ABC工作
我去牛津
我住在第一街
再见”
所以这些行是完全随机的,我想基于特定关键字,比如仅匹配“住在”一词,并对不同记录进行筛选,并在输出中捕获这些内容?
英文:

如何使用Talend从数据库的列中获取文本的一部分,然后使用tdbnput进行打印。

I have a talend job that goes like the above one and i am using a select statement to access the data from oracle

select id,name,details from employee ;

and send the results via email.However for a particular column details it has 10 different lines and that are dynamic and has various other unwanted/irrelevant information and i would like to precisely filter few lines and print them to the mail using tjava component.

How can i do that?

for eg:details column has values like:
"hi i am john
i work at abc
i go to oxford
i reside at 1st street
goodbye"
so the lines are totally random,i would want to match based on a specific keyword lets say "reside at" alone and filter that for different records and capture that in that output?

答案1

得分: 1

为了做到这一点,您需要在tDBinput中创建一个自定义的SQL查询。

"select id,name,details from employee
where details like '%reside at%'"

(其中 % 代表任何文本,请查阅SQL的 "LIKE" 函数以获取更多详情)

通过这样做,您将筛选出所需的行。如果您需要更多筛选条件,您可以按照您的意愿修改SQL查询。

英文:

In order to do this you need to create a custom SQL query in the tDBinput.

"select id,name,details from employee
where details like '%reside at%'"

(Where the % are any text check the SQL "LIKE" function for more details)

With this you will filter the row you want.
If you need more filter you can modify you SQL query like you want.

huangapple
  • 本文由 发表于 2020年10月23日 16:34:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/64496647.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定