MuleSoft: Connect PostgreSQL Database and Call PostgreSQL Function

What Is PostgreSQL?

PostgreSQL is an open source object-relational database system that uses and extends the SQL language to store and scale complicated data workloads.

A prerequisite to start with this walkthrough is to have a database connector added in Anypoint Studio. You can add these connectors from the Add modules option. Also, you need to have an ElephantSQL account, as we are going to use the PostgreSQL database hosted on the ElephantSQL platform. You can use any other PostgreSQL service provider platform or self-managed PostgreSQL server.

When to Code a Stored Procedure — and When Not To

Though it might seem to be a weird title in 2021, you'll be shocked to learn the number of applications (legacy and new) that still use stored procedures.

The stored procedure is a database capability that allows developers to write code at the level of the database and directly manipulate data (and sometimes define data, i.e. create tables, indexes, drop them, etc.,).

Send a Table-Valued Parameter to a MS SQL Stored Procedure in Mule 4

Introduction

Most of us have called a stored procedure in Mule to pass data to or receive data from database tables. However, one interesting variation of sending data via table-valued parameter (TVP) is not so commonly used. This article will show you how to send data in a TVP format to an MS SQL table via a stored procedure in Mule 4.

Before we proceed with the actual Mule development, let's first understand what a table-valued parameter is. As the name suggests, it is a parameter where data is sent in the form of a table, comprised of columns and rows. Within the database, table-valued parameters are declared by using user-defined table types. The main purpose of a TVP is to pass multiple values for a record, e.g. Multiple contact number values for a user record merged in the record itself. The benefit is that it associates the values, maintains the sequence, and reduces code complexity in the stored procedure.