title: Camel - camel-sql batch insert using useMessageBodyForSql
body: <p>I read in the documentation <a href="http://camel.apache.org/sql-component.html" rel="nofollow">here</a> that</p>
  
  <p>"If batch is set to true, then the interpretation of the inbound message body changes slightly – instead of an iterator of parameters, the component expects an iterator that contains the parameter iterators; the size of the outer iterator determines the batch size."</p>
  
  <p>"From Camel 2.16 onwards you can use the option useMessageBodyForSql that allows to use the message body as the SQL statement, and then the SQL parameters must be provided in a header with the key SqlConstants.SQL_PARAMETERS. This allows the SQL component to work more dynamic as the SQL query is from the message body."</p>
  
  <p>I have the following route:</p>
  
  <pre><code>  from("direct:processLine")
              .setHeader(SqlConstants.SQL_PARAMETERS, simple("${body}"))
              .setBody(constant("INSERT INTO SOME_TABLE "
                      " (Param1, Param2) " +
                      " values " +
                      " (:?Param1,:?Param2)"))
              .to("sql://query?useMessageBodyForSql=true&amp;batch=true&amp;dataSource=dataSource");
  </code></pre>
  
  <p>The body is a map of key/values matching the parameter list. </p>
  
  <p>This works, but not as expected. </p>
  
  <p>Each line is inserted one by one, instead of the expected batch insert. Is this combination of options even possible? </p>
  
  <p>If not possible, what would be an alternative way of accomplishing this? </p>