mule with stored procedure
TRANSCRIPT
![Page 1: Mule with stored procedure](https://reader036.vdocuments.net/reader036/viewer/2022083104/5882227d1a28ab52368b4661/html5/thumbnails/1.jpg)
Mule with Stored ProcedureFeroz Khan
![Page 2: Mule with stored procedure](https://reader036.vdocuments.net/reader036/viewer/2022083104/5882227d1a28ab52368b4661/html5/thumbnails/2.jpg)
Mule's database component allows us to connect with almost any Java Database Connectivity (JDBC) relational database and it has wonderful capabilities to perform various functionalities and run diverse SQL operations on our database, including Select, Insert, Update, Delete, and even Stored Procedures.
We will have a look here on how to use Stored Procedures with our Mule database component. So, before we start using Stored Procedures in our Mule, we will create a Stored Procedures in the database and then call to from our Mule application.
![Page 3: Mule with stored procedure](https://reader036.vdocuments.net/reader036/viewer/2022083104/5882227d1a28ab52368b4661/html5/thumbnails/3.jpg)
Creating a Store Procedure
![Page 4: Mule with stored procedure](https://reader036.vdocuments.net/reader036/viewer/2022083104/5882227d1a28ab52368b4661/html5/thumbnails/4.jpg)
So, we will get into our database and create a Stored Procedures there. In our case we will use MS SQL.Let's create Stored Procedure by following way :
Here, as we can see we have created a Stored Procedure called SP_TEST, which will take 2 inputs variable V1 and V2 and will sum it and return the total variable after adding both the variables.
![Page 5: Mule with stored procedure](https://reader036.vdocuments.net/reader036/viewer/2022083104/5882227d1a28ab52368b4661/html5/thumbnails/5.jpg)
After our Stored Procedure has been created successfully we will test it in following way :-
We can see here, we are passing 2 integer values in the input variables V1 and V2, and it's coming out with the total value as output with the addition of these 2 variables.
![Page 6: Mule with stored procedure](https://reader036.vdocuments.net/reader036/viewer/2022083104/5882227d1a28ab52368b4661/html5/thumbnails/6.jpg)
Stored Procedure with Mule
![Page 7: Mule with stored procedure](https://reader036.vdocuments.net/reader036/viewer/2022083104/5882227d1a28ab52368b4661/html5/thumbnails/7.jpg)
So, now we will try to call this Stored Procedure from our Mule application in following way :-
We can see here we are using Mule database component to call this Stored Procedure and passing 2 input parameter and 1 output parameter to display the result.
![Page 8: Mule with stored procedure](https://reader036.vdocuments.net/reader036/viewer/2022083104/5882227d1a28ab52368b4661/html5/thumbnails/8.jpg)
The corresponding Mule flow in graphical will be as following:-
![Page 9: Mule with stored procedure](https://reader036.vdocuments.net/reader036/viewer/2022083104/5882227d1a28ab52368b4661/html5/thumbnails/9.jpg)
Testing our application ……
![Page 10: Mule with stored procedure](https://reader036.vdocuments.net/reader036/viewer/2022083104/5882227d1a28ab52368b4661/html5/thumbnails/10.jpg)
Now, we are done with our coding and will deploy our application and test it.So, now if we will hit the url :- http://localhost:8081/test/test in browser, we will get the following result in Mule console :-
We can see here the Stored Procedure is called and we are getting the total value from our Mule application.
![Page 11: Mule with stored procedure](https://reader036.vdocuments.net/reader036/viewer/2022083104/5882227d1a28ab52368b4661/html5/thumbnails/11.jpg)
Conclusion
![Page 12: Mule with stored procedure](https://reader036.vdocuments.net/reader036/viewer/2022083104/5882227d1a28ab52368b4661/html5/thumbnails/12.jpg)
As we can see it's very simple to call any Stored Procedure from our Mule application as the database component of Mule supports diverse SQL operations and Stored Procedures on our Database.
That's all !!! I've hopefully been clear enough in displaying the implementation of database component and calling Stored Procedure from our Mule application.
I hope you liked this !!!
![Page 13: Mule with stored procedure](https://reader036.vdocuments.net/reader036/viewer/2022083104/5882227d1a28ab52368b4661/html5/thumbnails/13.jpg)
Hope you enjoyed the simple yet an amazing trick in Mule
You can also find this post here :- http://bushorn.com/mule-with-stored-procedure/
![Page 14: Mule with stored procedure](https://reader036.vdocuments.net/reader036/viewer/2022083104/5882227d1a28ab52368b4661/html5/thumbnails/14.jpg)
Thank You