You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Matteo Redaelli <ma...@libero.it> on 2009/04/03 10:45:23 UTC

camel-velocity: empty variable

ciao

I use velocity to build a sql statement. 

"
update mdl_user set
	idnumber='${in.body.cid}',icq='${in.body.usertype}'
where
	upper(username)=upper('${in.body.userid}')
"

it works fine if ${in.body.cid} and ${in.body.usertype} are not null
if one of them is null (for example ${in.body.cid}), after the execution of
the sql statement, the database field idnumber is not null (this is my wish)
but contains the string '${in.body.cid}'

what wrong? how could I solve it?


MY route is

		<route>
			<from uri="activemq:topic:user.update.response" />
			<to uri="velocity:sql-moodle-user-update.vm" />
			<to uri="jdbc:moodleDB" />
		</route>

Thanks in advance
Matteo
-- 
View this message in context: http://www.nabble.com/camel-velocity%3A-empty-variable-tp22864380p22864380.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: camel-velocity: empty variable

Posted by Matteo Redaelli <ma...@libero.it>.
Ok, now it works. Thank you for your help even if it was a issue related to
velocity and not camel
-- 
View this message in context: http://www.nabble.com/camel-velocity%3A-empty-variable-tp22864380p22887665.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: camel-velocity: empty variable

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Its Velocity that just renders it by default if the variable is not there
http://velocity.apache.org/engine/releases/velocity-1.6.2/user-guide.html#variables

You can use ! after the $ then it reneders a space instead
$!{in.body.cid) but if you want it to render null, then you probably
have to do some #if #else #end in VLT templating



On Fri, Apr 3, 2009 at 10:45 AM, Matteo Redaelli
<ma...@libero.it> wrote:
>
> ciao
>
> I use velocity to build a sql statement.
>
> "
> update mdl_user set
>        idnumber='${in.body.cid}',icq='${in.body.usertype}'
> where
>        upper(username)=upper('${in.body.userid}')
> "
>
> it works fine if ${in.body.cid} and ${in.body.usertype} are not null
> if one of them is null (for example ${in.body.cid}), after the execution of
> the sql statement, the database field idnumber is not null (this is my wish)
> but contains the string '${in.body.cid}'
>
> what wrong? how could I solve it?
>
>
> MY route is
>
>                <route>
>                        <from uri="activemq:topic:user.update.response" />
>                        <to uri="velocity:sql-moodle-user-update.vm" />
>                        <to uri="jdbc:moodleDB" />
>                </route>
>
> Thanks in advance
> Matteo
> --
> View this message in context: http://www.nabble.com/camel-velocity%3A-empty-variable-tp22864380p22864380.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Apache Camel Reference Card:
http://refcardz.dzone.com/refcardz/enterprise-integration