I want to insert multiple rows in mule database connector at a time. Could anyone kindly please help me on this?.
I can successfully insert the below message as a post request to a mule flow.
{
"patient_todo_id" : "2",
"comment_date" : "2017-09-20 14:41:16",
"comment_text" : "send me the steps to check the Pulse rate"
}
How to insert the below post message into a database in a mule flow?
[{
"patient_todo_id" : "2",
"comment_date" : "2017-09-20 14:41:16",
"comment_text" : "send me the steps to check the Pulse rate"
},
{
"patient_todo_id" : "2",
"comment_date" : "2017-09-20 14:41:16",
"comment_text" : "send me the steps to check the Pulse rate"
}]
Please find the below mule flow configuration file which has been configured to insert a single row at a time.
<flow name="carrotcube-patient-todo-commentFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="${http.path.mrs.todo.comment}" doc:name="HTTP"/>
<set-variable variableName="variable" value="#[payload]" mimeType="application/json" doc:name="Variable"/>
<json:json-to-object-transformer returnClass="java.lang.Object" doc:name="JSON to Object"/>
<logger message="#[payload.comment_text]" level="INFO" doc:name="Logger"/>
<db:insert config-ref="MySQL_Configuration" doc:name="Database">
<db:parameterized-query><![CDATA[insert into patient_todo_detail(patient_todo_id,comment_date,comment_text) values (#[payload.patient_todo_id],#[payload.comment_date],#[payload.comment_text])]]></db:parameterized-query>
</db:insert>
</flow>