You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Shiv <sh...@gmail.com> on 2015/12/15 20:44:48 UTC

Using Message Headers & Body into Camel SQL Insert statement

Hi,
I want to insert a record in table using camel sql component and want to
externalize the insert query in a properties file. Seems it is not working
fine as simple expression in properties is not getting replaced by actual
value.

#Insert query in properties file - this is not working
SQLInsertQuery=insert into Message (messageId, messageBody)
values('$simple{in.header.JMSMessageID}', '$simple{in.body}')

#Insert query in properties file - this is also not working
SQLInsertQuery=insert into Message (messageId, messageBody)
values('${in.header.JMSMessageID}', '${in.body}')

#Insert query in properties file - this is also not working
SQLInsertQuery=insert into Message (messageId, messageBody)
values(:#${header.JMSMessageID}, :#${body}')


My route calls below but insert is failing in call cases.
<to uri="sql:{{SQLInsertQuery}}"/>

Am I missing anything in expression?

Thanks for input.
Shiv




--
View this message in context: http://camel.465427.n5.nabble.com/Using-Message-Headers-Body-into-Camel-SQL-Insert-statement-tp5775107.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Using Message Headers & Body into Camel SQL Insert statement

Posted by Shiv <sh...@gmail.com>.
Thanks for the reply.

Headers are getting accessible with :#HeaderName format. Any idea how we can
access the body?



--
View this message in context: http://camel.465427.n5.nabble.com/Using-Message-Headers-Body-into-Camel-SQL-Insert-statement-tp5775107p5775269.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Using Message Headers & Body into Camel SQL Insert statement

Posted by Matt Sicker <bo...@gmail.com>.
Headers are already interpolated like :#headerName. I've never tried using
expressions in SQL like that.

On 15 December 2015 at 13:44, Shiv <sh...@gmail.com> wrote:

> Hi,
> I want to insert a record in table using camel sql component and want to
> externalize the insert query in a properties file. Seems it is not working
> fine as simple expression in properties is not getting replaced by actual
> value.
>
> #Insert query in properties file - this is not working
> SQLInsertQuery=insert into Message (messageId, messageBody)
> values('$simple{in.header.JMSMessageID}', '$simple{in.body}')
>
> #Insert query in properties file - this is also not working
> SQLInsertQuery=insert into Message (messageId, messageBody)
> values('${in.header.JMSMessageID}', '${in.body}')
>
> #Insert query in properties file - this is also not working
> SQLInsertQuery=insert into Message (messageId, messageBody)
> values(:#${header.JMSMessageID}, :#${body}')
>
>
> My route calls below but insert is failing in call cases.
> <to uri="sql:{{SQLInsertQuery}}"/>
>
> Am I missing anything in expression?
>
> Thanks for input.
> Shiv
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Using-Message-Headers-Body-into-Camel-SQL-Insert-statement-tp5775107.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Matt Sicker <bo...@gmail.com>