简体   繁体   中英

Mule4 Bulk insert after map in dataweave prompting an error for field contains multiple object

I am trying to insert bulk data to mssql after batch processing.

Below is the input to bulk insert component in Mule4: [ { "schemaId": 311, "createDT": "2019-04-29 04:22:51.535", "jsonData": { "Employee Name": "Becky Forgey" } }, { "schemaId": 311, "createDT": "2019-04-29 04:22:51.536", "jsonData": { "Employee Name": "sahana" } } ] Database Query is:

INSERT INTO [test].[dbo].[EmployeeData] (SchemaID,CreateDatetime,JsonData) VALUES (:schemaId,:createDT,:jsonData)

INPUT parameter is payload.

If i send a string value for jsonData it is inserting but batch result consists of multiple records and i am mapping it in dataweave.

Getting below error if i try to insert above json:

Message               : The conversion from UNKNOWN to NVARCHAR is unsupported.
Error type            : DB:QUERY_EXECUTION
Element               : test-mapFlow/processors/5 @ test-map:test-map.xml:41 (Bulk insert)
Element XML           : <db:bulk-insert doc:name="Bulk insert" doc:id="98f8b9a0-b3d2-4beb-a31c-9f76af7f1447" config-ref="Database_Config">
<db:sql>INSERT INTO [rq].[dbo].[EmployeeMasterData] (SchemaID,CreateDatetime,JsonData) VALUES (:schemaId,:createDT,:jsonData)</db:sql>
</db:bulk-insert>

Please guide

Please, provide full script how you present data for the SQL. Usually it has mapping between your values and sql values. Without it I can only guess and my guess is that instead of jsonData ir should be jsonData."Employee Name"

Another guess - I cannot confirm it without proper logging - jsonData is absent. To avoid such issues defualt value should be provided for each parameter.

In general - try to avoid muitple conversions or do them on one platform as close to end as possible https://simpleflatservice.com/mule4/AvoidCoversionsOrMakeThemNative.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM