Q:

camel path syntax for select query and transferring the data into insert query for postgresql

I am using camel 2.15 and java 1.7 for my enterprise application.  Our database is  postgresql 9.4.0.  
I am trying to configure camel route for a scenario where my requirement is to read data from one postgresql schema with a select query and insert the same data into another postgresql schema.  
I have used the below syntax for fetching the data from postgresql - 
from("timer://foo?period="+serverData.getTimer()).threads(serverData.getNumberOfInstances()).setBody(constant(serverData.getSql())). 
to("jdbc:" + serverData.getUrl() + serverData.getUserId() + "? outputType=SelectList"). 
process(custom application logic)

With the above syntax, I can able to fetch the data and able to process into custom logic present in process method.  
Note - In the above syntax, serverData class is used to get the postgresql connection details and sql details. 
Now, my problem is - how do I define the camel route so that selected data can be directly inserted into another postgresql table by an insert query.  
I have tried using below syntax without any success. 
from("timer://foo?period="+serverData.getTimer()).threads(serverData.getNumberOfInstances()).setBody(constant(serverData.getSql())). 
setBody(constant("insert into new_raw_table (numbersubscribers,id) values(:?numbersubscribers,:?id)")). 
to("jdbc:" + serverData.getUrl() + serverData.getUserId()). 
process(custom application logic)

OR
from("timer://foo?period="+serverData.getTimer()).threads(serverData.getNumberOfInstances()).setBody(constant(serverData.getSql())). 
to("jdbc:" + serverData.getUrl() + serverData.getUserId() + "? consumer.onConsume=insert into new_raw_table(NumberSubscribers,ID) values(:#NumberSubscribers,:#ID)");
process(custom application logic)

Neither syntax can insert the selected data from one postgresql to another postgresql schema. 

A:

You have 2 query but only one jdbc endpoint.  I think, you need to use another one jdbc endpoint with another datasource, because you have another database.  
But this does not solve the problem of two queries in a single transaction.  More information about transactional client can be found here: http://camel.apache.org/transactional-client.html
UPDATED 2:
from("timer://foo?period="+serverData.getTimer())
  .threads(serverData.getNumberOfInstances())
  .setBody(constant(serverData.getSql()))
  .to("jdbc:" + serverData.getUrl() + serverData.getUserId())
  //Think about query parameters, based on first query result
  //You need to define them, by default the result is returned in the OUT body 
  //ArrayList<HashMap<String, Object>> in the OUT body
   .to("log:before-split?level=INFO&showAll=true&multiline=true")
   .split(body()) //because you received more then one record
   .to("log:after-split?level=INFO&showAll=true&multiline=true")
   .process(new Processor() {
        @Override
        public void process(Exchange exchange) throws Exception {
            //Record of first query after splitter in the Map
            Map<String, Object> record = exchange.getOut().getBody(Map.class);
            exchange.getIn().setHeader("numbersubscribers",  record.get("numbersubscribers"));
            exchange.getIn().setHeader("id",  record.get("id"));
        }
    })
   .to("log:before2query?level=INFO&showAll=true&multiline=true")
   .setBody(constant("insert into new_raw_table (numbersubscribers,values(:?numbersubscribers,:?id)"))

  .to("jdbc:".....) //You have to refer here to another datasource, maybe like below
 //jdbc:embeddedDataSource?allowNamedParameters=true&outputType=SelectOne&useHeadersAsParameters=true&resetAutoCommit=false
  .process(custom application logic);

