You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by jamie3 <ja...@gmail.com> on 2016/07/07 15:21:45 UTC

Dynamically changing SQL with INSERT

I am trying to automatically create the SQL query for inserting data into
Oracle using SQL component. I have not found much documentation related to
this. Any ideas?


from("jms:queue:INPUT.Q")
		.routeId("ens reports log route")
		.convertBodyTo(String.class)
		.process(new Processor() {
			@Override
			public void process(Exchange exchange) throws Exception {
				exchange.getIn().setBody("INSERT INTO Test VALUES ('" +
exchange.getIn().getBody() + "')?dataSource=#dataSource");
			}
		})
		.to("sql:?dataSource=#dataSource");



--
View this message in context: http://camel.465427.n5.nabble.com/Dynamically-changing-SQL-with-INSERT-tp5784938.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Dynamically changing SQL with INSERT

Posted by arno noordover <an...@gmail.com>.
A lot depends on what you are trying to achieve.
I would try to use "bind"-variables as in the examples on
http://camel.apache.org/sql-component.html
But this depends on the fact of you being able to predict what field you
need to insert.
e.g
sql:select * from table where id=:#myId order by name[?options]

or

sql:select * from table where id=:#${property.myId} order by name[?options]



--
View this message in context: http://camel.465427.n5.nabble.com/Dynamically-changing-SQL-with-INSERT-tp5784938p5784961.html
Sent from the Camel - Users mailing list archive at Nabble.com.