How To Post Data Using Stored Procedure With MuleSoft

This article is the continued part of the MuleSoft series and the next part of the last posted article. Before jumping into this article, I highly recommended reading the previous article: How To Call Stored Procedure with MuleSoft

If you would like to understand the basics of MuleSoft, refer to these articles before going next:

So, we assume the MuleSoft project is set up and Listener (HTTP configured). Let’s see what our post stored procedure and other settings is.

This is a basic stored procedure to insert data in the table:

How to Post Data using Stored Procedure with MuleSoft

Now drag and drop Database > Stored procedure from Mule Palette and setup the following properties:

  • Display name - Annotation for database stored procedure.
  • Connector configuration - Connector configuration selection.
  • SQL Query Text - Stored procedure call with parameter names.
  • Input Parameters - Input parameters, which will pass to proc. I will call the API from the Postman and pass the parameters from there. That’s why passing the entire payload.

How to Post Data using Stored Procedure with MuleSoft

Now drag and drop Transform Message (Core) from Mule Palette and provide payload, as I am not returning anything after record creation. I am just setting up a successful message in JSON form.

How to Post Data using Stored Procedure with MuleSoft

That’s it. Now deploy the project to see the result.

How to Post Data using Stored Procedure with MuleSoft

All looks good, and you see DEPLOYED status without any error message. Now open Postman and provide API URL and input parameters in Body.

How to Post Data using Stored Procedure with MuleSoft

As you can see, the record is created successfully, let’s check in the database if the record is there or not.

How to Post Data using Stored Procedure with MuleSoft

Here you go, the record was inserted successfully.

Conclusion

In this article, we learned how to call SQL Stored Procedure to insert the data in the database with input parameters in MuleSoft.


Similar Articles