简体   繁体   中英

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}

<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

I think the concatenation between $ {body} and% is wrong

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.

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

Finally I get this working with this snippet:

(It's scala but it's practically the same)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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