Dynamically changing SQL with INSERT

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Dynamically changing SQL with INSERT

jamie3
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");
Reply | Threaded
Open this post in threaded view
|

Re: Dynamically changing SQL with INSERT

arno noordover
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]