I'm new to database connector in Mule 3.7.3. I'm trying to insert bulk data using INSERT statement that formed dynamically. I don't know what do you guys usually call this approach, what I intend to do is, load multiple files into respective staging table dynamically, instead of having multiple choice routes and hard code the INSERT statement in each route.
My flowVars.insertStatement contains value like this: "INSERT INTO [roomService] ([RoomId],[ServiceId],[DateTime]) VALUES (#[payload.roomId],#[payload.serviceId],#[payload.dateTime])"
When I tried with these:
<db:insert config-ref="Staging_DB" doc:name="insert-data-into-staging-db" bulkMode="true">
<db:parameterized-query><![CDATA[#[flowVars.insertStatement]]]></db:parameterized-query>
This gives me "Query type must be one of '[INSERT, STORE_PROCEDURE_CALL]' but was 'DDL' (java.lang.IllegalArgumentException)"
<db:insert config-ref="Staging_DB" doc:name="insert-data-into-staging-db" bulkMode="true">
<db:dynamic-query><![CDATA[#[flowVars.insertStatement]]]></db:dynamic-query>
This gives me "Bulk query cannot contain a parameterized SQL query (java.lang.IllegalArgumentException)"
<db:insert config-ref="Staging_DB" doc:name="insert-data-into-staging-db" bulkMode="true">
<db:dynamic-query><![CDATA[#[flowVars.insertStatement]]]></db:dynamic-query>
This gives me "Index: 0 (java.lang.IndexOutOfBoundsException)"
I need some pointers how to do this correctly. Please advise.