Bulk Insert In Database Using Mule Database Connector

 

In this tutorial we will demonstrate how can you use Bulk Insert operation In Database Using Mule Database Connector and insert multiple rows at a time.

The insertupdate, and delete operations can be used for the cases in which each input parameter can take only one value. Alternatively, bulk operations allow you to run a single query using a set of parameters values.

You can avoid unnecessary steps by doing a bulk operation so that:

  • The query is parsed only once.
  • Only one database connection is required since a single statement is executed.
  • Network overhead is minimized.
  • RDBMS can execute the bulk operation atomically.

Create a project and add HTTP listener to call the API

 

Drag and Drop bulk insert connector

 

Create a DB connection

Bulk Insert In Database Using Mule Database Connector

 

Add the insert query as below

 

Set input parameter as

Bulk Insert In Database Using Mule Database Connector

 

Now add a transformation

Bulk Insert In Database Using Mule Database Connector

 

Here metadata for the output will be pre-populated and can see it accept the Array of the input object, here we are mapping data for two countries.

Run the application using – http://localhost:8081/insert

 

And now we can see the data added in Target table –

 

Sample application – http://mulesy.com/wp-content/uploads/2019/01/oracle-db-bulk-insert.zip

  
Thank you for taking out time to read the above post. Hope you found it useful. In case of any questions, feel free to comment below. Also, if you are keen on knowing about a specific topic, happy to explore your recommendations as well.
 
For any latest updates or posts on our website, you can follow us on LinkedIn. Look forward to connecting with you there.


Share this:
Subscribe
Notify of
guest
4 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
siva
siva
4 years ago

what are input parameters and sql parameters for bulk insert data from post man

Lê Vũ Hoàng Khanh
3 years ago
Reply to  siva

It should a post request with body content like:

{
  sql: "INSERT INTO TBL_A(COL1, COL2) VALUES(:val1, :val2)",
  params: [
    {val1: 1, val2: 2},
    {val1: 3, val2: 4}
  ]
}
Bhargav
Bhargav
2 years ago

how many inserts can bulk insert handle?
I have a file with 50K records(one record is one row in db) will it be able insert all the records?

Nishant
Nishant
10 months ago
Reply to  Bhargav

Send them in Chunks