简体   繁体   English

apache camel sql:要求与

[英]apache camel sql : request with like

hello i'm stuck in this problem i have a query that take in setting the value of $ {body} 你好,我被困在这个问题中,我有一个查询,用于设置$ {body}的值

<to uri="sql:SELECT distinct substr(cust_account,4,3) as TypeCompte from bnaservice.customer_accounts where cust_account like '#${body[0]}%' order by cust_account?dataSource=moodleDB"/>
<to uri="bean:tn.ngtrend.CompteClientRest.Transformer?method=ToXml(Exchange)"/>

the value of $ {body} equal 001 but each time I execute the query it gives me a result null $ {body}的值等于001,但是每次执行查询时,结果都为空

I think the concatenation between $ {body} and% is wrong 我认为$ {body}和%之间的串联是错误的

is there anyone who can help me solve this problem,thanks 有谁能帮助我解决这个问题,谢谢

Can you try to use a colon? 您可以尝试使用冒号吗? Because body is like a named parameter. 因为body就像一个命名参数。

like ':#${body[0]}%'

If this still does not work, I would try to concatenate the expression and the % in an Exchange property and then call the property in the SQL statement 如果仍然无法解决问题,我将尝试在Exchange属性中连接表达式和% ,然后在SQL语句中调用该属性

Finally I get this working with this snippet: 最终,我使用以下代码片段进行工作:

(It's scala but it's practically the same) (这是scala,但实际上是相同的)

transform("%" + _.in[String] + "%")
to("sql:SELECT * FROM quotes WHERE quote LIKE :#${body} ORDER BY RANDOM() LIMIT 1")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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