camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: dynamic sql request
Date Fri, 07 Aug 2009 10:49:52 GMT
On Fri, Aug 7, 2009 at 12:45 PM, Roman
Kalukiewicz<roman.kalukiewicz@gmail.com> wrote:
> You can also use SQL component this way:
>
> from("jms:q_in")
> .transform(XPathBuilder.xpath("/Listes/Liste/id").stringResult())
> .to("sql:SELECT * FROM v_test WHERE indv=#")
> .to("somewhere else");
>

Cool maybe we/you should add that as an example to the SQL component wiki page

> Roman
>
> 2009/8/7 Claus Ibsen <claus.ibsen@gmail.com>:
>> On Thu, Aug 6, 2009 at 7:09 PM, abdes<aelabbassi@gmail.com> wrote:
>>>
>>> Hi,
>>> i have diffficult to pass parameter from exchange content to SQL request :
>>> here my code :
>>>
>>> exchange content :
>>> <Listes>
>>> <Liste>
>>>  <id>123456</id>
>>> </Liste>
>>> <Liste>
>>>  <id>123456</id>
>>> </Liste>
>>> <Listes>
>>>
>>>
>>> from("jms:q_in")
>>> .enrich("direct:resource", new ExampleAggregationStrategy())
>>> .to("direct:result");
>>>
>>>
>>>
>>> from("direct:resource")
>>> .setBody(constant("SELECT * FROM v_test WHERE indv =XXXX"))
>>>
>>> That i want, is to pass <Listes><Liste><id>  value to indv
parameter.
>>> How can i process ?
>>>
>>
>> The XML above is that content from the JMS message?
>>
>> Do you need the XML afterwards or only need to grab the <id> tag?
>>
>> You can use XPath to select the XML node of choice. But also use a
>> POJO to fetch it?
>> In the POJO you can even set the result as the SQL statement directly
>>
>> For starters you can use a plain Processor that is a bit low level but
>> gives you power in regular Java code to work with it.
>>
>> To get the data as XML you can use
>>
>> Document doc = exchange.getIn().getBody(Document.class);
>>
>> from(jms)
>> process(new MyIdToSQLProcessor())
>> .to("jdbc:myDatasource")
>> .to("somewhereelse");
>>
>>
>>
>> And in relation to the constant language. Camel provides a bit more
>> powerful the simple language that allows you to build strings dynamic
>> http://camel.apache.org/simple.html
>>
>> And then there are all the others with a real programming language underneath
>> http://camel.apache.org/languages.html
>>
>>
>>> Regards
>>>
>>>
>>> --
>>> View this message in context: http://www.nabble.com/dynamic-sql-request-tp24850692p24850692.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
>>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Mime
View raw message