SK SKYVVA Documentation

How to call stored procedure with SQL Server on Agent?

Introduction

A store procedure is a set of SQL statements with an assigned name, stored in an RDBMS as a group so that multiple programs can reuse and share it. Stored procedures can access or modify data in a database, but it is not tied to a specific database or object, which offers a number of advantages.

In this tutorial, we use the SQL Server database as an example. Here, when we call the Stored Procedure to the Database to do any database operation, we expect it will respond back the result to Salesforce. In this case, we need to have the INPUT and OUTPUT parameters in the Stored Procedure and create a Request and Response Interface corresponding to those parameter types. The SQL Server database is located on an EC2 instance and the Stored Procedure was written to Insert new data if no record is present on the Database and update data if the record exists.

Pre-required

How to call Stored Procedure with SQL Server on Agent?

Step1: Create Integration and test connection destination

Create new Integration by following the guide, the link is given below:

https://apsara-consulting.com/docs/tutorial-v2-41-lightning/what-is-an-integration-and-how-to-create-it/

Step2: Create Outbound and Inbound Database Adapter for connection to the SQL Server database presented on the EC2 instance

Name: any name

Step3: generate Message Type from the database

Fill in all required information then click the button Retrieve Database

[su_box title="Note" box_color="#2a8af0" title_color="#000000"]

For Database Stored Procedure, we have a template for generating Message Type for a single Table

[/su_box]

Step4: Set up the Interface

Create an inbound interface for synchronous mode, operation(upsert), choose Adapter, Metadata Provider, Repository, and Message Type (Response)

Step5: Linking Response Interface to Request Interface

In this example Request Interface name is “Request Interface” and Response Interface name is “Request Interface”

Step6: Checking Cache status

Before sending data from salesforce to Agent or from Agent to salesforce, we need to check on Cache Monitor and make sure the Cache record is present on H2.

Step7: Manual Process

Check the result on Message Monitoring

The Stored Procedure has been executed and responded to Salesforce correctly

Here is the result on SQL Server

Open this article in the interactive viewer →