- 15 Feb 2024
- 2 Minutes to read
- Print
- DarkLight
Using Stored Procedure in Flows
- Updated on 15 Feb 2024
- 2 Minutes to read
- Print
- DarkLight
Feature Details | |
Modified in Version | 8.18 |
Location | System → Integration → Databases |
Stored Procedures are queries that run in MSSQL with an EXEC command. Stored Procedures can perform queries on the database table to update, add, delete, select, or edit data. Stored Procedures can be integrated to create steps that can execute the Stored Procedure and move the input values from the Flow to the database table.
Although this document refers to MSSQL throughout, everything here applies to MYSQL.
Errors with MSSQLPlease partner with a database or system administrator or use internet resources to configure the Stored Procedure in MSSQL. If there are errors that occur while creating a Stored Procedure, please use Microsoft's Stored Procedures support documentation. Decisions cannot troubleshoot MSSQL operations outside of its relation to the Decisions platform. Ensure the testing environment is appropriate to proceed.
Prerequisites
MSSQL Database
PostgreSQL IntegrationDecisions use Functions rather than Procedures for PostgreSQL when setting up a Stored Procedure for a PostgreSQL integration.
Adding Store Procedure to Decisions
In this example, a Stored Procedure has been created that adds a new person to the specified database table. To add the example store procedure, run the following SQL query in the connected database.
CREATE PROCEDURE AddPerson (
@PersonID text,
@FirstName text,
@Lastname text,
@DOB datetime) AS
Begin
INSERT INTO dbo.person ([PersonID], [FirstName], [Lastname], [DOB])
Values (@PersonID, @FirstName, @Lastname, @DOB)
END
GO
Navigate to System (gear icon) → Integrations → Databases .
From the top action panel, Click ADD PROCEDURE. On the Add Procedure window, choose the appropriate Procedure Name from the drop-down menu.
The Procedure Definition Name will automatically populate. In the All Parameters window, inputs appear configured in the Stored Procedure, where the data type of the expected value also appears.
If desired, select the Returns Data option to add input parameters for creating a Data Structure when running the Stored Procedure. Click OK.
Store Procedure Steps Configurations
Store procedure steps are located in the Toolbox → Integration → Database → [DatabaseName] → Exec dbo.[StoreProcedureName]. The following table describes the settings available on the Store Procedure Steps.
Environment Setting | Description |
---|---|
Use Transaction | This setting allows you to manage transactions associated with the stored procedure execution.
|
Run in Defined Environment | This setting, when enabled (as it is by default), the stored procedure will be executed in a predefined or default environment. |
Run without Transaction |
If transactions are not needed for a specific stored procedure, this setting allows you to exclude them. |
Override Connection String | This setting, when enabled, allows you to provide a custom database connection string instead of using the default connection. |
Using Store Procedure Steps in a Flow
In a Designer Project, click CREATE FLOW.
In the Toolbox panel, navigate to INTEGRATION → DATABASE → [DATABASENAME] and attach the Exec dbo.AddPerson to the Start and End steps.
Debug
On the top action bar, click Debug.
Click START DEBUGGING.
Open MSSQL and use a select statement or the menu command to show the updated database table.
The inputs mapped to the Exec Flow step were recorded to the database table as the Stored Procedure was called from the Flow.
Feature Changes
Description | Version | Developer Task |
---|---|---|
Added a new setting on the Store Procedure Steps to Run without Transaction | [DT-026523] |