Hi

So you want the value to be null, eg

VALUE (100, null)

And does the database understand null ?




On Mon, Dec 8, 2014 at 6:50 PM, Schulze, Jan
<[email protected]> wrote:
> Hi all,
>
> in Camel 2.13.2, I'm transferring data from one database to another like so:
>
> .setBody(simple("SELECT fieldA, fieldB FROM table1 LIMIT 1"))
>     .to("jdbc:DataSourceService1")
>
> .split(body())
> .log("${body })  // This logs: {fieldA=100, fieldB=null}
>
> .setBody(simple("INSERT INTO table2(fieldA, fieldB) VALUES (${body[fieldA]}, 
> ${body[fieldB]})"))
>     .to("jdbc:DataSourceService2")
>
> In the INSERT statement, the null value of fieldB is converted to an empty 
> string,
> resulting in something like: INSERT INTO table2(fieldA, fieldB) VALUES (100, )
>
> Is it possible to avoid this conversion? I could use a custom Processor
> or check the length of ${body[fieldB]} before using it,
> but I would like to keep the route as simple as possible.
>
> So is there any other way?
>
>
> Best Regards,
> --
> Jan Schulze



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: [email protected]
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Reply via email to